The C pre-processor in CW 10.3 does not seem to follow the C standards for #define. It replaces the name that is part of another name. For example, if I define C1, it will modify MCG_C1.
Does anyone know if there is a preference setting that will make it act like satndard C?
已解决! 转到解答。
Pascal, Thanks for replying.
I have found the problem.
I have a #define C1 ... that I used for a configuration bit.
In MCUinit.c there is a line MCG_C1 = ...
MCG_C1 is a macro that uses C1 which is defined as an element of a structure.
The error that I get is "expected identifier before '(' token". That didn't tell me anything.
I would have hoped that I would get a warning message if I used a name that was already defined in MKL05Z4.h
Bruce
Hi,
I've created an example under MCU V10.4.
I don't reproduced the problem.
C code:
++++++++++++++
#define C1 1
int main(void)
{
int counter = 0;
#if C1
for(;;) {
counter++;
}
#endif
return 0;
}
++++++++++++++
pre-process file
++++++++++++++
# 1 "<command-line>" 2
# 1 "..\\Sources\\main.c"
# 14 "..\\Sources\\main.c"
int main(void)
{
int counter = 0;
for(;;) {
counter++;
}
return 0;
}
++++++++++++++
I've checked with the Compiler Preprocess option -DC1 too.
On my side it seems to work fine.
Please can you provide us more details to reproduce the issue?
Pascal
Pascal, Thanks for replying.
I have found the problem.
I have a #define C1 ... that I used for a configuration bit.
In MCUinit.c there is a line MCG_C1 = ...
MCG_C1 is a macro that uses C1 which is defined as an element of a structure.
The error that I get is "expected identifier before '(' token". That didn't tell me anything.
I would have hoped that I would get a warning message if I used a name that was already defined in MKL05Z4.h
Bruce