1

I did a lot of searches in the forums about the problem I have to use _Generic primary expression in my code. I wrote a macro to get the data type of variable using the _Generic functionality:

#define CHECK_DATA_TYPE(x) _Generic((x),        /* Get the name of a type */             \
     bool: DATA_TYPE_BOOL,          \
     u8  : DATA_TYPE_U8,            \
     s8  : DATA_TYPE_S8,             \
     u8  : DATA_TYPE_U16,            \
     s8  : DATA_TYPE_S16,             \
     u8  : DATA_TYPE_U32,            \
     s8  : DATA_TYPE_S32)

so far in the code, I call the macro :

u8 test = 10; u8 val = CHECK_DATA_TYPE(test);

So, I have a compilation error which indicate that the _Generic function is not defined:

W1020B: warning: identifier "_Generic" is undefined E4254B: type name is not allowed E4018B: expected a ")" E4065B: expected a ";"

Any ideas? It's important to indicate that I compiled my project using Softune C Compiler.

klutt
  • 30,332
  • 17
  • 55
  • 95

1 Answers1

2

_Generic was introduced in C11. It seems that the Softune don't support that version. I cannot find a definite statements, but in the manual I read this:

For C language syntax and standard library functions, refer to commercially available ANSI standard compliant reference books.

So possibly, it could be the case it only support ANSI C, which is C89.

It seems like you're out of luck. You have to write the code without the _Generic keyword.

klutt
  • 30,332
  • 17
  • 55
  • 95