On 10/05/2012 10:06 AM, Andreas Schwab wrote: > Chet Ramey <chet.ra...@case.edu> writes: > >> Why would you say there's a restriction against using casts or sizeof in >> a macro like this? > > Because it must expand to a valid preprocessor expression.
C99 5.2.4.2.1 Sizes of integer types <limits.h> 1. The values given below shall be replaced by constant expressions suitable for use in #if preprocessing directives. Moreover, except for CHAR_BIT and MB_LEN_MAX, the following shall be replaced by expressions that have the same type as would an expression that is an object of the corresponding type converted according to the integer promotions. <stdint.h> and <limits.h> are the two main headers that are this explicit about various macros being suitable for use in preprocessor arithmetic, and preprocessor arithmetic cannot use casts or sizeof. -- Eric Blake ebl...@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature