* Improving the cxx0x_warning.h diagnostic
@ 2015-11-26 14:50 Jonathan Wakely
[not found] ` <CAF1jjLte9e7nJx5o91s2DgcHzYkveHatMqmeSm404=4s+a0jMw@mail.gmail.com>
0 siblings, 1 reply; 2+ messages in thread
From: Jonathan Wakely @ 2015-11-26 14:50 UTC (permalink / raw)
To: libstdc++; +Cc: gcc-patches
We have lots of headers that do this:
#if __cplusplus < 201103L
# include <bits/c++0x_warning.h>
#else
and that file has a #error (not #warning as the name would suggest).
Unfortunately a #error does not stop compilation, so when users try to
compile C++11 source code (which includes standard headers) and they
don't use the right -std option, they are likely to get that #error
message, followed by a cascade of later errors due to the use of C++11
syntax or library types.
We could solve this!
--- a/libstdc++-v3/include/bits/c++0x_warning.h
+++ b/libstdc++-v3/include/bits/c++0x_warning.h
@@ -29,9 +29,11 @@
#define _CXX0X_WARNING_H 1
#if __cplusplus < 201103L
-#error This file requires compiler and library support for the \
-ISO C++ 2011 standard. This support is currently experimental, and must be \
-enabled with the -std=c++11 or -std=gnu++11 compiler options.
+#error This file requires compiler and library support for at least \
+the ISO C++ 2011 standard, which must be enabled with \
+the -std=c++11 or -std=gnu++11 compiler options.
+// Include a non-existent file to terminate compilation:
+#include <__no_such_header__>
#endif
#endif
When a header cannot be included we stop during preprocessing and
never even try to compile the C++11 code that follows , so the user
gets nothing more than:
In file included from /home/jwakely/gcc/6/include/c++/6.0.0/thread:35:0,
from th.cc:1:
/home/jwakely/gcc/6/include/c++/6.0.0/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for at least the ISO C++ 2011 standard, which must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
#error This file requires compiler and library support for at least \
^~~~~
/home/jwakely/gcc/6/include/c++/6.0.0/bits/c++0x_warning.h:36:30: fatal error: __no_such_header__: No such file or directory
#include <__no_such_header__>
^
compilation terminated.
I'm not very happy with the __no_such_header__ part, but we could
bikeshed a better name. The point is that the compilation stops
immediately, and the last errors printed are the ones about using the
wrong -std option.
Is this a good idea?
Too late for 6.0?
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Improving the cxx0x_warning.h diagnostic
[not found] ` <CAF1jjLte9e7nJx5o91s2DgcHzYkveHatMqmeSm404=4s+a0jMw@mail.gmail.com>
@ 2015-11-27 18:55 ` Jonathan Wakely
0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Wakely @ 2015-11-27 18:55 UTC (permalink / raw)
To: NightStrike; +Cc: libstdc++, GCC Patches
On 27/11/15 12:53 -0500, NightStrike wrote:
>You could add a pragma that turns on -Wfatal-errors
That might be better, I'll try it, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-11-27 18:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-26 14:50 Improving the cxx0x_warning.h diagnostic Jonathan Wakely
[not found] ` <CAF1jjLte9e7nJx5o91s2DgcHzYkveHatMqmeSm404=4s+a0jMw@mail.gmail.com>
2015-11-27 18:55 ` Jonathan Wakely
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).