Date: Sun, 21 Jun 2026 15:07:24 +0100
On Sun, 21 Jun 2026 at 11:56, amngis_21d38 via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>
> Why is Hello World for C++23 so large?
This question is off-topic for this mailing list and a wall of text
from nm output is not useful to anybody.
puts is defined in libc.so so your program just gets an undefined
reference to it.
std::print is defined inline in the libstdc++ headers so your program
contains the entire definition of std::print and std::format etc.
If you link your puts.c program with -static so that the definition of
puts is included in the binary you'll see it grow significantly.
See the libstdc++ manual for a workaround for the experimental
std::print implementation being defined inline:
_GLIBCXX_NO_INLINE_PRINT
Undefined by default. When defined std::print and std::println are not
implemented using inline functions. This means that code using those
functions will compile faster, but -lstdc++exp must be used when
linking. The non-inline definitions are compiled using
-fexec-charset=UTF-8 so might give incorrect results if called from a
source file that uses a non-Unicode encoding, especially for format
strings using non-ASCII fill characters.
Compiling with -D_GLIBCXX_NO_INLINE_PRINT -lstdc++exp will still
include the whole definition of std::print (because -lstdc++exp links
to it statically) but print.cpp will make a single call to an extern
function, instead of instantiating all the std::format internals.
Please find a more suitable place to discuss this further.
<std-proposals_at_[hidden]> wrote:
>
> Why is Hello World for C++23 so large?
This question is off-topic for this mailing list and a wall of text
from nm output is not useful to anybody.
puts is defined in libc.so so your program just gets an undefined
reference to it.
std::print is defined inline in the libstdc++ headers so your program
contains the entire definition of std::print and std::format etc.
If you link your puts.c program with -static so that the definition of
puts is included in the binary you'll see it grow significantly.
See the libstdc++ manual for a workaround for the experimental
std::print implementation being defined inline:
_GLIBCXX_NO_INLINE_PRINT
Undefined by default. When defined std::print and std::println are not
implemented using inline functions. This means that code using those
functions will compile faster, but -lstdc++exp must be used when
linking. The non-inline definitions are compiled using
-fexec-charset=UTF-8 so might give incorrect results if called from a
source file that uses a non-Unicode encoding, especially for format
strings using non-ASCII fill characters.
Compiling with -D_GLIBCXX_NO_INLINE_PRINT -lstdc++exp will still
include the whole definition of std::print (because -lstdc++exp links
to it statically) but print.cpp will make a single call to an extern
function, instead of instantiating all the std::format internals.
Please find a more suitable place to discuss this further.
Received on 2026-06-21 14:07:45
