C pre-processor for #define

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

C pre-processor for #define

Jump to solution
990 Views
wba
Contributor III

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?

Labels (1)
Tags (1)
0 Kudos
1 Solution
742 Views
wba
Contributor III

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

View solution in original post

0 Kudos
7 Replies
742 Views
wba
Contributor III

Hi Pascal,

I am using the Kinetis MKL05Z8VLC4.

0 Kudos
742 Views
trytohelp
NXP Employee
NXP Employee

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

0 Kudos
743 Views
wba
Contributor III

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

0 Kudos
742 Views
trytohelp
NXP Employee
NXP Employee

Hi Bruce,

So problem is solved.

The C1 was already defined in  header file.

Pascal

0 Kudos
742 Views
trytohelp
NXP Employee
NXP Employee

Hi Bruce,

Are you using GNU or Freescale compiler ?

Pascal

0 Kudos
742 Views
trytohelp
NXP Employee
NXP Employee

Hi Bruce,

Only GCC compiler is available for this architecture.

I will check it and keep you informed.

Pascal

0 Kudos
742 Views
trytohelp
NXP Employee
NXP Employee

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

0 Kudos