bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: examples/loadables/getconf.c


From: Eric Blake
Subject: Re: examples/loadables/getconf.c
Date: Fri, 05 Oct 2012 10:17:34 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120911 Thunderbird/15.0.1

On 10/05/2012 10:06 AM, Andreas Schwab wrote:
> Chet Ramey <chet.ramey@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   eblake@redhat.com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]