This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Stipping away locale support


Bernardo Innocenti wrote:
> This was as good as one would expect. But this one isn't:
>
> ---------------------------------------------------------------------
> #include <iostream> // unused!
> int main()
> {
>         printf("Hello, world!\n");
> }
>
>    text    data     bss     dec     hex filename
>  193783   70696    4896  269375   41c3f hello.gdb
> ---------------------------------------------------------------------

This is expected. #include <iostream> causes an object of type
ios_base::Init to be defined. The constructor of this object
constructs the standard streams cin, cout, etc. This requires
(almost) all of iostreams, strings and locales to be included in
the executable.

This should probably be noted in
http://gcc.gnu.org/onlinedocs/libstdc++/27_io/howto.html#10

> And an even better one:
> 
> ---------------------------------------------------------------------
> // no headers at all!
> int main()
> {
> 	char *c = new char[20];
> }
>    text    data     bss     dec     hex filename
>  193751   70600    4896  269247   41bbf hello.gdb
> ---------------------------------------------------------------------

That's strange. On Cygwin this last example is much smaller
than the previous one. This should require only the definitions
of operator new[](size_t), exception and bad_alloc (thrown if
operator new[] fails) and terminate (called if the exception is
thrown since there is no catch handler) [1]; the linker should
discard the object files containing the rest of the library.

Regards,
Petur

[1] It seems the situation isn't quite this ideal, for example,
set_terminate, set_unexpected, set_new_handler and
uncaught_exception are included even though they are not used.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]