Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20130313172343.GF20323@brightrain.aerifal.cx>
Date: Wed, 13 Mar 2013 13:23:43 -0400
From: Rich Felker <dalias@...ifal.cx>
To: musl@...ts.openwall.com
Subject: Re: inttypes.h: possible logical error?

On Wed, Mar 13, 2013 at 12:26:44PM -0400, Zvi Gilboa wrote:
> Greetings,
> 
> In inttypes.h, the first "actual" lines read:
> 
> ....
> #include <features.h>
> #include <stdint.h>
> 
> #define __NEED_wchar_t
> #include <bits/alltypes.h>
> ....
> 
> As it seems, the idea is to have <bits/alltypes.h> processed with
> __NEED_wchar_t  already defined.  However, <bits/alltypes.h> is also
> included by <stdint.h>.
> 
> In a way this is rather harmless, specifically since
> <bits/alltypes.h> can be processed more than once, yet wouldn't it
> be more logical and/or consistent to #define __NEED_wchar_t  prior
> to including <stdint.h>?  Given no conflicting considerations, the
> above code snippet would then read:
> 
> ....
> #define __NEED_wchar_t
> 
> #include <features.h>
> #include <stdint.h>
> #include <bits/alltypes.h> /* possibly redundant?  see stdint.h */
> ....
> 
> Thanks in advance for any and all feedback!

I wouldn't call it an error. It's a suboptimality, but the tradeoff is
that one header (inttypes.h) is not making assumptions about the
implementation of the other. If others want to see this changed to
save an #include, we could consider it, but it would need to be
commented that the optimization depends on the implementation of
stdint.h.

Rich

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.