Sujet : Re: "A diagram of C23 basic types"
De : Keith.S.Thompson+u (at) *nospam* gmail.com (Keith Thompson)
Groupes : comp.lang.cDate : 03. Apr 2025, 20:29:21
Autres entêtes
Organisation : None to speak of
Message-ID : <85ldshjb72.fsf@nosuchdomain.example.com>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13
User-Agent : Gnus/5.13 (Gnus v5.13)
David Brown <
david.brown@hesbynett.no> writes:
On 03/04/2025 20:31, Keith Thompson wrote:
bart <bc@freeuk.com> writes:
[...]
I understand C23 mode will be enabled by a compiler option (-std=c23);
the same method could have been used to enable all std headers, and
for that to be the default.
The standard says exactly nothing about compiler options.
"-std=c23"
is a convention used by *some* compilers (gcc and other compilers
designed to be compatible with it).
Hello World then becomes this one-liner:
>
int main() {puts("Hello, World!");}
A compiler could provide such an option as a non-conforming
extension
with no change in the standard. I'm not aware that any compiler
has done so, or that there's been any demand for it. One reason
for the lack of demand might be that any code that depends on it
is not portable. (Older versions of MS Visual Studio create a
"stdafx.h" header, but newer versions appear to have dropped that.)
>
gcc provides such an option :
>
gcc -include stdio.h hello_world.c
>
If someone really wanted to, they could easily make a shell script,
bash alias, Windows bat file, or whatever, as a wrapper for gcc with a
whole bunch of "-include" options for all the standard headers.
I wouldn't call that "such an option". The kind of option being
discussed is one that would implicitly include *all* the standard
headers.
Sure, you could use it in a wrapper script, but it would be just
as easy to write a wrapper script that generates and compiles a
source file that includes all the standard headers and the source
file and then compiles that (with a #line directive so diagnostic
messages refer to the original source file).
My point is that, as far as I'm aware, nobody has implemented
"implicitly include all the standard headers", either as a compiler
option or as a wrapper script. I'm sure somebody has (I could do
it in a few minutes), but it's just not something that programmers
appear to want.
Of course part of the motivation for *not* wanting this is that
it results in non-portable code, and if it were standardized that
wouldn't be an issue.
And if it were standardized, <assert.h> would raise some issues,
since NDEBUG needs to be defined or not defined before including it.
-- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.comvoid Void(void) { Void(); } /* The recursive call of the void */