Hi,everyone!
When I compile my C coding, there was an error that C2801: ' ; ' missing. The codes are as follows.
#define FAN_LOWSPEED_OFF() PTDDD_PTDDD5 = 1;\
IO_vResetPin(PTED_PTED0)
I don't know much about the macro declaration. Is there anything wrong with my codes?
Any ideas about dealing with my errors?
Thanks much for your replies.
Solved! Go to Solution.
Hello
CodeWarrior supports nested macros.
But you need to make sure the macro IO_vResetPin is defined prior to FAN_LOWSPEED_OFF.
Additionally when you have parameter inside of macros it is a good practice to enclose the parameter name in parenthesis
For example:
#define IO_vResetPin(PinName) (PinName) = 0
As general note when you are using macros in an ANSI C module, if you get into trouble, check the preprocessor listing.
This listing will show you how the preprocessor expands the various macros and will allow you to detect any error using the macros.
CrasyCat
Hello
I am missing some context information in order to answer properly.
But as far as I can tell IO_vResetPin is a function you are invoking,
I would first try to add a semicolon at the end of IO_vResetPin(PTED_PTED0).
If that does not help generate the preprocessor listing for the source file and inspect the code at the location where the macro is expanded.
This might give you a clue.
CrasyCat
CrasyCat wrote:Hello
I am missing some context information in order to answer properly.
But as far as I can tell IO_vResetPin is a function you are invoking,
I would first try to add a semicolon at the end of IO_vResetPin(PTED_PTED0).
If that does not help generate the preprocessor listing for the source file and inspect the code at the location where the macro is expanded.
This might give you a clue.
CrasyCat
CrasyCat wrote:Hello
I am missing some context information in order to answer properly.
But as far as I can tell IO_vResetPin is a function you are invoking,
I would first try to add a semicolon at the end of IO_vResetPin(PTED_PTED0).
If that does not help generate the preprocessor listing for the source file and inspect the code at the location where the macro is expanded.
This might give you a clue.
CrasyCat
Thanks very much, CrasyCat.
I've worked it out. In fact, IO_vResetPin() is also a macro decfinition.The codes are as follows.
#define IO_vResetPin(PinName) PinName = 0
I used PTED_PTED0 = 0 instead of IO_vResetPin(PTED_PTED0). And as you said, I added a semicolon at the end of
PTED_PTED0 = 0. It was ok.
I wonder if codewarrior doesn't support macro definition nesting.
Thanks very much for your replies.
Hello
CodeWarrior supports nested macros.
But you need to make sure the macro IO_vResetPin is defined prior to FAN_LOWSPEED_OFF.
Additionally when you have parameter inside of macros it is a good practice to enclose the parameter name in parenthesis
For example:
#define IO_vResetPin(PinName) (PinName) = 0
As general note when you are using macros in an ANSI C module, if you get into trouble, check the preprocessor listing.
This listing will show you how the preprocessor expands the various macros and will allow you to detect any error using the macros.
CrasyCat
Hello,
There was actually a further level of macro nesting used. PTED_PTED0 is also a macro that defines an element of a bit field.
Regards,
Mac
Hi,
You are right. So, CrasyCat is also right.
Thank you.