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: TR library extensions


Gabriel Dos Reis wrote:
Pétur Runólfsson <peturr02@ru.is> writes:

| Gabriel Dos Reis wrote:
| > | A -std= option is needed that adds include/tr1 to the include path,
| > | because the new tr1 headers should not be visible if -std=c++98 is
| > | given.
| > | > Why?
| | Consider the program
| | #include <tuple>
| int main() { }
| | The documentation for the -std switch says:
| Specify the standard to which the code should conform
| This code doesn't conform to C++ 98 (because there is no header named
| <tuple>). Shouldn't the compiler reject it when -std=c++98 is
| specified?


I see no reason. Do you also propose to reject

#include <unistd.h>


FWIW, the reason to reject the program above is for strict conformance (i.e., to make it easier to detect programs that are not portable to other implementations). The difference between your example and the one given by Petur is that the <unistd.h> header doesn't come with gcc while <tuple> presumably will. Gcc has little control over the headers that come with the operating system (and the conformance of those to the various standards is left up to their implementors, and in POSIX is typically controlled by macros such as _POSIX_VERSION, etc.), but it does have complete control over its own implementation of the language.

So I agree with Petur: a quality implementation of C++ such as gcc
should provide an option for programs to choose the version of the
C++ standard they want to conform to, and the compiler should
diagnose detectable violations when the option is selected.

Regards
Martin


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