### Question 10.13

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

References: ANSI Sec. 2.1.1.2, Sec. 3.8.1 footnote 83
ISO Sec. 5.1.1.2, Sec. 6.8.1
H&S Sec. 7.11.1 p. 225

Read sequentially: prev next up top

This page by Steve Summit // Copyright 1995 // mail feedback