mailing list of musl libc
 help / color / mirror / code / Atom feed
* inttypes.h: possible logical error?
@ 2013-03-13 16:26 Zvi Gilboa
  2013-03-13 17:23 ` Rich Felker
  0 siblings, 1 reply; 3+ messages in thread
From: Zvi Gilboa @ 2013-03-13 16:26 UTC (permalink / raw)
  To: musl

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!

Best regards,
Zvi Gilboa



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: inttypes.h: possible logical error?
  2013-03-13 16:26 inttypes.h: possible logical error? Zvi Gilboa
@ 2013-03-13 17:23 ` Rich Felker
  2013-03-13 17:53   ` Zvi Gilboa
  0 siblings, 1 reply; 3+ messages in thread
From: Rich Felker @ 2013-03-13 17:23 UTC (permalink / raw)
  To: musl

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: inttypes.h: possible logical error?
  2013-03-13 17:23 ` Rich Felker
@ 2013-03-13 17:53   ` Zvi Gilboa
  0 siblings, 0 replies; 3+ messages in thread
From: Zvi Gilboa @ 2013-03-13 17:53 UTC (permalink / raw)
  To: musl

Thank you, Rich, for the quick feedback!  You are of course absolutely 
right...

Best regards,
Zvi





On 03/13/2013 01:23 PM, Rich Felker wrote:
> 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



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-03-13 17:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-13 16:26 inttypes.h: possible logical error? Zvi Gilboa
2013-03-13 17:23 ` Rich Felker
2013-03-13 17:53   ` Zvi Gilboa

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).