lpcware

Struct forward declaration throws errors

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by fjrg76 on Tue Sep 04 20:48:46 MST 2012
Hi,

While programming upon LPCXpresso 4.2, I wanted to use struct's forward declarations, but the compiler throws errors. This is a snippet form my code:

[FONT=Courier New]
[COLOR=Red]typedef _CHRONOMETER_T CHRONOMETER_T;[/COLOR]

struct _CHRONOMETER_T
{
volatile uint32_t msec;
volatile uint32_t sec;
volatile uint32_t min;
int32_t calibration;
};

[COLOR=Red]CHRONOMETER_T cronometro;[/COLOR]

[COLOR=Red]void chrono_Init(CHRONOMETER_T * me, int32_t calibrationValue)[/COLOR]
{
me->msec=0;
me->sec=0;
me->min=0;
me->calibration=calibrationValue;
}
...
[/FONT]

The code in red is where the compiler is founding errors, but I can't see why. No matter where the "typedef..." line is set, the error is still showing up. If I do this the compilation process ends with success:

[FONT=Courier New]struct _CHRONOMETER_T cronometro;
...
void chrono_Init(struct _CHRONOMETER_T * me, int32_t calibrationValue){}
[/FONT]

What Am I missing?

Thank you in advanced :)

Outcomes