C pre-processor for #define

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

C pre-processor for #define

ソリューションへジャンプ
1,463件の閲覧回数
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?

ラベル(1)
タグ(1)
0 件の賞賛
返信
1 解決策
1,215件の閲覧回数
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 件の賞賛
返信
7 返答(返信)
1,215件の閲覧回数
wba
Contributor III

Hi Pascal,

I am using the Kinetis MKL05Z8VLC4.

0 件の賞賛
返信
1,215件の閲覧回数
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 件の賞賛
返信
1,216件の閲覧回数
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 件の賞賛
返信
1,215件の閲覧回数
trytohelp
NXP Employee
NXP Employee

Hi Bruce,

So problem is solved.

The C1 was already defined in  header file.

Pascal

0 件の賞賛
返信
1,215件の閲覧回数
trytohelp
NXP Employee
NXP Employee

Hi Bruce,

Are you using GNU or Freescale compiler ?

Pascal

0 件の賞賛
返信
1,215件の閲覧回数
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 件の賞賛
返信
1,215件の閲覧回数
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 件の賞賛
返信