Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

#ifndef __GNUC__ choke me

Tags:

c

gnu

This question might be totally strange, I am currently working on some old code (not from me). I am actually no C programmer, but I am trying to understand what this part of the code is actually supposed to do. Luckily the strange part isn't to long (part of a configuration):

int
main ()
{
#ifndef __GNUC__
       choke me
#endif

  ;
  return 0;
}

If it is not a GNU compiler then "choke me"...what is this choke me supposed to mean...I really don't get it. (and found only strange things while googling choke me -.-)

like image 277
Steffen Moritz Avatar asked Sep 16 '25 20:09

Steffen Moritz


1 Answers

It's just supposed to be something that's not valid C and will trigger a syntax error, preventing the file from compiling.

Presumably the programmer didn't intend the code to work with any compiler except GNU C (gcc), so this will force the build to fail if any other compiler is used. There is no special significance to the words chosen, except that "choke me" was probably meant in the sense of "this is something the compiler can't 'swallow' and which will kill it."

The more modern approach would be to use #error.

like image 70
Nate Eldredge Avatar answered Sep 19 '25 09:09

Nate Eldredge