Use of _generic c99 Macro functionality

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

Use of _generic c99 Macro functionality

993件の閲覧回数
emiel_84
Contributor I

Hi,

 

I'm using codewarrior 10.5 build id 130916. My project is written in C.

The idea I did have was to add a _generic macro , to enable other files to only know\use just one interface definition.

For some reason it keeps complaining that the _Generic is unknown.

" error: expected ',' or ';' before '_Generic' "

 

 

call in c-file

[code]

int value1;

Function_GET2(value1)

BOOL value2

Function_GET2(value2)

[/code]

 

in the h-file:

[code]

void Function_GET_ValueA(BOOL item);

void Function_GET_ValueB(int item);

 

 

#define Function_GET2(X) _Generic((X), int: Function_GET_ValueA, BOOL: Function_GET_ValueB)(X)

 

[/code]

 

I have set the project C compiler to language standard ISO C99 with GNU Extensions, because I did read that _Generic was supported in version C99.

 

Therefore my question is what can I check\verify\change in Codewarrior that should be set to support the _Generic type.

ラベル(1)
0 件の賞賛
返信
3 返答(返信)

661件の閲覧回数
ZhangJennie
NXP TechSupport
NXP TechSupport

hello,

CodeWarrior 10.6 comes with gcc 4.7.3. KDS3.0 has the newer version 4.8.0.

so far as i know we don't have a tool integrated gcc4.9.

Erich ever wrote article about how to switch gcc4.7 to CW10.3. please try if the same method can work for gcc4.9

Switching ARM GNU gcc Toolchain in Eclipse | MCU on Eclipse


Have a great day,
Jennie Zhang

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 件の賞賛
返信

661件の閲覧回数
emiel_84
Contributor I

Seems like the gcc is to old.

gcc needs to be add version 4.9 at least for _Generic support.

Code-warrior seems to be using 4.7.3 ( link: Comparing CodeWarrior with Kinetis Design Studio | MCU on Eclipse )

Seems I will not be able to use it unfortunately or did someone found a solution to get this working in code-warrior?

0 件の賞賛
返信

661件の閲覧回数
emiel_84
Contributor I

I have fixed a small issue:  output is now:

" implicit declaration of function '_Generic' [-Wimplicit-function-declaration] "

0 件の賞賛
返信