Bug 112699 - Should limits.h in freestanding environment be self-contained?
Summary: Should limits.h in freestanding environment be self-contained?
Status: UNCONFIRMED
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 14.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-11-24 10:36 UTC by Xi Ruoyao
Modified: 2023-11-24 17:50 UTC (History)
5 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Xi Ruoyao 2023-11-24 10:36:40 UTC
Currently limits.h always includes the libc limits.h if it's available at build time.  Should it be self-contained instead like stdint.h with -ffreestanding?
Comment 1 Alexander Monakov 2023-11-24 11:15:12 UTC
Can you clarify which file you mean? gcc/ginclude does not have a limits.h.

I assume you are not talking about the fixinclude'd limits.h?
Comment 2 Alexander Monakov 2023-11-24 11:24:41 UTC
Sorry, even though GCC's limits.h is installed under include-fixed, it is generated separately, not by the generic fixincludes mechanism. I was confused.
Comment 3 Xi Ruoyao 2023-11-24 13:35:30 UTC
(In reply to Alexander Monakov from comment #1)
> Can you clarify which file you mean? gcc/ginclude does not have a limits.h.
> 
> I assume you are not talking about the fixinclude'd limits.h?

No, I mean the limits.h in $(dirname $(gcc -print-libgcc-file-name)).  It currently contains these lines to include libc limits.h:

#ifndef _LIBC_LIMITS_H_
/* Use "..." so that we find syslimits.h only in this same directory.  */
#include "syslimits.h"
#endif

(if libc limits.h is fixinclude'd, it will be saved to syslimits.h; otherwise syslimits.h will just contain "#include_next <limits.h>".)

And I'm asking if

#ifndef _LIBC_LIMITS_H_ && !__STDC_HOSTED__
/* Use "..." so that we find syslimits.h only in this same directory.  */
#include "syslimits.h"
#endif

would be better?