Interview Questions

Does the sizeof operator work in preprocessor if directives?

C Interview Questions and Answers


(Continued from previous question...)

Does the sizeof operator work in preprocessor if directives?

No. Preprocessing happens during an earlier phase of compilation, before type names have been parsed. Instead of sizeof, consider using the predefined constants in ANSI's <limits.h>, if applicable, or perhaps a ``configure'' script. (Better yet, try to write code which is inherently insensitive to type sizes;

(Continued on next question...)

Other Interview Questions