Click here to Skip to main content
14,362,801 members

C / C++ / MFC

 
GeneralRe: gcc configure for hardware Pin
leon de boer22-Nov-18 22:48
memberleon de boer22-Nov-18 22:48 
GeneralRe: gcc configure for hardware Pin
Vaclav_26-Nov-18 5:09
memberVaclav_26-Nov-18 5:09 
GeneralRe: gcc configure for hardware Pin
Vaclav_26-Nov-18 7:54
memberVaclav_26-Nov-18 7:54 
GeneralRe: gcc configure for hardware Pin
Vaclav_29-Nov-18 18:11
memberVaclav_29-Nov-18 18:11 
GeneralRe: gcc configure for hardware Pin
Vaclav_30-Nov-18 5:44
memberVaclav_30-Nov-18 5:44 
Questionproblems with pointer to struct Pin
Mohammad Ali Bahar19-Nov-18 0:15
memberMohammad Ali Bahar19-Nov-18 0:15 
AnswerRe: problems with pointer to struct Pin
CPallini19-Nov-18 1:20
mveCPallini19-Nov-18 1:20 
AnswerRe: problems with pointer to struct Pin
leon de boer19-Nov-18 6:19
memberleon de boer19-Nov-18 6:19 
Each structure inside is a pointer and needs to be allocated and even worse this is inherently dangerous because
any of those pointers could be NULL if an error occurred and that line will crash.
output->engine->water_temp = NORMAL;

What you are building is a database and as the entries are small there is no advantages to allocation and pointers,
you only do pointers if the data is going to be large. Just place the structure in as is.
typedef enum
{
	NORMAL = 0,
	WARNING = 1,
} WATER_TEMP;

typedef struct {
	WATER_TEMP water_temp;
	uint16_t speed;
	// ... other members
} Engine_t;

typedef struct
{
	Engine_t engine;  // <== Not a pointer anymore
	// ... other members
} ECU_t;

int main(void)
{
	/* This creates a test instance .. requires C99 or higher wont work on old C89 compiler */
	ECU_t ecu_test = { .engine.water_temp = NORMAL,
		           .engine.speed = 10 };

        /* You access them in the normal way */
	printf("Water temp is %i\n", ecu_test.engine.water_temp);
	printf("Engine speed is %i\n", (unsigned int)ecu_test.engine.speed);
}

In vino veritas

GeneralRe: problems with pointer to struct Pin
Mohammad Ali Bahar19-Nov-18 9:47
memberMohammad Ali Bahar19-Nov-18 9:47 
GeneralRe: problems with pointer to struct Pin
leon de boer19-Nov-18 15:13
memberleon de boer19-Nov-18 15:13 
AnswerRe: problems with pointer to struct Pin
Joe Woodbury19-Nov-18 19:13
professionalJoe Woodbury19-Nov-18 19:13 
QuestionText Access Pin
Bram van Kampen17-Nov-18 15:49
memberBram van Kampen17-Nov-18 15:49 
AnswerRe: Text Access Pin
Richard MacCutchan17-Nov-18 22:06
protectorRichard MacCutchan17-Nov-18 22:06 
QuestionHow to close a sub Dialogwindow without closing a Parent Dialogwindow in MFC C++ VS2010? Pin
Member 1312800516-Nov-18 23:09
memberMember 1312800516-Nov-18 23:09 
SuggestionRe: How to close a sub Dialogwindow without closing a Parent Dialogwindow in MFC C++ VS2010? Pin
Richard MacCutchan17-Nov-18 0:20
protectorRichard MacCutchan17-Nov-18 0:20 
QuestionRe: How to close a sub Dialogwindow without closing a Parent Dialogwindow in MFC C++ VS2010? Pin
David Crow17-Nov-18 4:57
memberDavid Crow17-Nov-18 4:57 
AnswerRe: How to close a sub Dialogwindow without closing a Parent Dialogwindow in MFC C++ VS2010? Pin
Bram van Kampen17-Nov-18 15:51
memberBram van Kampen17-Nov-18 15:51 
QuestionLinked List Problem - K reverse linked list Pin
Member 1405554315-Nov-18 1:04
memberMember 1405554315-Nov-18 1:04 
AnswerRe: Linked List Problem - K reverse linked list Pin
CPallini15-Nov-18 1:24
mveCPallini15-Nov-18 1:24 
GeneralRe: Linked List Problem - K reverse linked list Pin
Stefan_Lang15-Nov-18 4:43
memberStefan_Lang15-Nov-18 4:43 
GeneralRe: Linked List Problem - K reverse linked list Pin
CPallini15-Nov-18 7:07
mveCPallini15-Nov-18 7:07 
AnswerRe: Linked List Problem - K reverse linked list Pin
Daniel Pfeffer15-Nov-18 3:16
professionalDaniel Pfeffer15-Nov-18 3:16 
AnswerRe: Linked List Problem - K reverse linked list Pin
Stefan_Lang15-Nov-18 5:19
memberStefan_Lang15-Nov-18 5:19 
QuestionRe: Linked List Problem - K reverse linked list Pin
David Crow15-Nov-18 6:37
memberDavid Crow15-Nov-18 6:37 
Questionfacing issue in “Ajantha” font on windows10 in GDIplus Pin
Avinash.Pandey12-Nov-18 23:06
memberAvinash.Pandey12-Nov-18 23:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.