On Fri, Nov 14, 2014 at 8:18 AM, Jakub Jelinek <ja...@redhat.com> wrote:
> On Tue, Nov 11, 2014 at 11:46:55AM +0100, Richard Biener wrote:
>> > BTW: There are lots of places where std::swap can be used, a nice
>> > search-and-replace task for someone to start with gcc development. ;)
>>
>> Agreed ;)  Note that we have to be careful to avoid pulling all of libstdc++
>> into all files via system.h (system.h is so a bad thing... :/).
>
> Apparently the nvptx port is another thing that fails to build because of
> the header ordering issues, this time not just when starting with clang, but
> just when building cross-compiler starting from gcc 4.9.1 on x86_64.
>
> There is:
>
> #include "config.h"
> #include "system.h"
> ...
> #include "hashtab.h"
> #include <sstream>
>
> and I get:
> g++ -c   -g  -DIN_GCC  -DCROSS_DIRECTORY_STRUCTURE  -fno-exceptions -fno-rtti 
> -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings 
> -Wcast-qual -Wmissing-format-attribute -Woverloaded-virtual -pedantic 
> -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -fno-common  
> -DHAVE_CONFIG_H -I. -I. -I../../gcc -I../../gcc/. -I../../gcc/../include 
> -I../../gcc/../libcpp/include  -I../../gcc/../libdecnumber 
> -I../../gcc/../libdecnumber/dpd -I../libdecnumber -I../../gcc/../libbacktrace 
>    -o nvptx.o -MT nvptx.o -MMD -MP -MF ./.deps/nvptx.TPo 
> ../../gcc/config/nvptx/nvptx.c
> In file included from /usr/include/c++/4.9.1/bits/basic_ios.h:37:0,
>                  from /usr/include/c++/4.9.1/ios:44,
>                  from /usr/include/c++/4.9.1/istream:38,
>                  from /usr/include/c++/4.9.1/sstream:38,
>                  from ../../gcc/config/nvptx/nvptx.c:54:
> /usr/include/c++/4.9.1/bits/locale_facets.h:240:53: error: macro "toupper" 
> passed 2 arguments, but takes just 1
>        toupper(char_type *__lo, const char_type* __hi) const
>                                                      ^
> and many more.
> As you said that we don't want to pull all of libstdc++
> headers via system.h, looking at system.h, I see just the
>
> /* Define this so that inttypes.h defines the PRI?64 macros even
>    when compiling with a C++ compiler.  Define it here so in the
>    event inttypes.h gets pulled in by another header it is already
>    defined.  */
> #define __STDC_FORMAT_MACROS
>
> macro being critical to be included before any system headers,
> can't we move that into config.in/auto-host.h and just suggest
> header ordering of
>
> #include "config.h"
> #include <sstream> // or any other extra STL headers not provided by system.h 
> you need
> #include "system.h"
> all other includes

Ick.

> ?  There are also some comments about stdarg.h and stdio.h ordering,
> dunno what it comes from and if it is still relevant when we require
> C++ compiler.

I think we should simply discourage people from using sstream for
example.

But I don't see how we can live without system.h with all the weird
host systems still around - thus your solution above will very likely
not work.

Eventually we can split system.h into a c-system.h and cxx-system.h
so we can distinguish between uses in files compiled with a C and
a C++ compiler?

Richard.

>         Jakub

Reply via email to