3

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 -.-)

Steffen Moritz
  • 7,277
  • 11
  • 36
  • 55

2 Answers2

3

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.

Nate Eldredge
  • 48,811
  • 6
  • 54
  • 82
  • 1
    Ahhh ok, so it's kind of metapher from the former programmer, that if it's not a GNU compiler, it should break, because it won't work anyway? – Steffen Moritz Sep 04 '20 at 02:38
  • 2
    Yes. That’s the intent. It could also have been any sentence like: Fail, because GNU C is required. – user2864740 Sep 04 '20 at 02:39
  • Ah, ok I see. Haha, "Fail, because GNU C is required", would have saved me some minutes ... not counting the minutes I was weighting if it is really a good idea to post this strange choke me code on SO ;) Anyway, thanks a lot! – Steffen Moritz Sep 04 '20 at 02:47
  • 2
    Historical note: The string "choke me" has been used for this purpose in GNU Autoconf since at least 1993. – Ture Pålsson Sep 04 '20 at 07:15
2

It's an invalid statement, so would result in an error.

Some programmer dude
  • 400,186
  • 35
  • 402
  • 621