__STDC_VERSION__ not defined in C++11?

I tried to get __STDC_VERSION__ with gcc 4.8 and clang, but it just not defined. Compiler flags:

g++ -std=c++11 -O0 -Wall -Wextra -pedantic -pthread main.cpp && ./a.out

http://coliru.stacked-crooked.com/a/b650c0f2cb87f26d

#include <iostream>
#include <string>

int main()
{
    std::cout << __STDC_VERSION__  << std::endl;
}

As result:

main.cpp:6:18: error: '__STDC_VERSION__' was not declared in this scope

I have to include some header, or add compiler flags?


P.S. Does someone knows compiler predefined macros, to check generic lambdas existence? For example gcc 4.8 may work in -std=c++1y mode, but still not support generic lambdas (while gcc 4.9 does).

Answers


The official documentation states:

__STDC_VERSION__

...

This macro is not defined if the -traditional-cpp option is used, nor when compiling C++ or Objective-C.

Also, the C++ standard(s) leave it up to the implementation to define this macro or not, and g++ opted for the latter.

Depending on what you're trying to do the __cplusplus macro might be an alternative (it is not just defined, it has a value, too ;)


Need Your Help

SQL php connect three tables

php sql

I am a begginer programmer and I want to ask something about SQL and PHP. So, I have 3 tables in the database, the first one is a table 't1'that store information about a user

mutual exclusion in joomla

joomla mutual-exclusion

I created an extension for joomla using:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.