ProgrammingModerateProduct company OA

What does `_Static_assert(sizeof(long) >= 8, "need 64-bit long");` do in C11?

  1. A. Checks the condition at run time and aborts the program if it fails
  2. B. Stops compilation with the given message if the condition is false on this platform
  3. C. Prints the message as a warning but continues compiling
  4. D. Changes long to 64 bits if it is smaller

Correct answer: B. Stops compilation with the given message if the condition is false on this platform

_Static_assert evaluates a constant expression at compile time and makes the compilation fail with the message if it is false. It costs nothing at run time; assert from <assert.h> is the run-time check.

More C Programming questions

Exams that ask this topic