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 Pascal,
I am using the Kinetis MKL05Z8VLC4.
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
Hi Bruce,
So problem is solved.
The C1 was already defined in header file.
Pascal
Hi Bruce,
Are you using GNU or Freescale compiler ?
Pascal
Hi Bruce,
Only GCC compiler is available for this architecture.
I will check it and keep you informed.
Pascal
Hi Bruce,
what is the processor used ?
The MCU V10.3 and V10.4 (last version) are including several archiectures and so different build tool chain.
Regards
Pascal