C++ dialect

Feb 21, 2012 at 11:46am
How do I know which dialect of C++ am I programming with(C++98, C++03, C++11 etc.)?
Feb 21, 2012 at 11:59am
If this compiles, you're using C++11:
auto foo=[](){};

Otherwise, you're using C++98/C++03. There are no real practical differences between the two.
Feb 21, 2012 at 12:50pm
and how to know which c++ compiler has c++11? I dont see it anywhere and google doesnt realy help.
Feb 21, 2012 at 12:58pm
Recent versions of major compilers all support C++11 to varying degrees.
There is no compiler that supports it fully yet.
See this page for an overview:
http://wiki.apache.org/stdcxx/C++0xCompilerSupport
Feb 21, 2012 at 1:14pm
Ok, I might, just might have totaly messed up my c++. I updated my gcc compiler with a version 4.6., the last one was 3.(something), and now it won't let me include iostream! it says something about some constant expresions blablabla... Anywho, is it possible to DOWNGRADE my gcc?
Feb 21, 2012 at 1:19pm
I don't see why you would want to do that. Purge your installation, then install Code::Blocks or wxDevC++, install the latest MinGW and set the toolchain path to the newly installed compiler.

http://www.codeblocks.org/downloads
http://forums.codeblocks.org/index.php?topic=15945.0

http://wxdsgn.sourceforge.net/

http://tdm-gcc.tdragon.net/download
Feb 21, 2012 at 1:22pm
yes, but it seems that gcc that supports c++11 doesn't support iostream! And i need iostream!
Feb 21, 2012 at 1:26pm
Of course it supports iostream. You just messed up something in your compiler setup or the path settings.
Feb 21, 2012 at 1:32pm
I just went to the defount "look for upgrades" options, clicked gcc v. 4.6.2, and installed it. there is no way I messed something up.
Oh, and I erased my whole previous c++ and reinstalled it and now it works
Feb 21, 2012 at 1:36pm
That information isn't very useful without knowing what IDE you use.
Feb 21, 2012 at 1:36pm
what's an IDE?
Feb 21, 2012 at 1:42pm
Oh, i looked it up. Ok, so it would be.. Bloodshed DEVC++ v. 4.9.9.2
Feb 21, 2012 at 1:42pm
It's what you call "c++". C++ is just a language specification, but to actually develop C++ applications, you need an IDE (consisting of an editor and all sorts of other tools) and/or a C++ compiler.

http://en.wikipedia.org/wiki/Integrated_development_environment
Feb 21, 2012 at 1:43pm
I just told you! I looked it up on wikipedia and tol you my IDE!
Last edited on Feb 21, 2012 at 1:43pm
Feb 21, 2012 at 2:21pm
Yeah, see: http://www.cplusplus.com/articles/36vU7k9E/
Install one of the IDEs I mentioned or Eclipse CDT if you want to keep using g++.
Feb 21, 2012 at 3:22pm
> How do I know which dialect of C++ am I programming with(

The problem is that to be able to check than from within C++, you need a compiler that defines the preprocessor macro __cplusplus as specified by the appropriate IS. (for instance GCC 4.7).

if __cplusplus == 199711L then it is C++98
if __cplusplus == 201103L then it is C++11

1
2
3
4
5
6
#include <iostream>

int main()
{
    std::cout << __cplusplus << '\n' ;
}


> g++ -std=c++98 -pedantic -Wall -Werror test.cc && ./a.out
199711
> g++ -std=c++11 -pedantic -Wall -Werror test.cc && ./a.out
201103


In practice, the current level of C++11 feature support is partial and varies from compiler to compiler. Boost.Config would be quite handy if specific feature support needs to be checked.
http://www.boost.org/doc/libs/1_48_0/libs/config/doc/html/boost_config/boost_macro_reference.html

Last edited on Mar 3, 2012 at 7:50pm
Feb 25, 2012 at 7:25pm
If I type std::cout << __cplusplus << '\n' ; it returns
1
!
what is that?
Feb 26, 2012 at 4:47am
It is some sort of a C++ compiler all right, but:
Either: It is a pre-standard C++ compiler (before C++ had an International Standard)
Or: It is a compiler that does not define the preprocessor macro __cplusplus in accordance with the IS. (for example, GCC versions prior to 4.7)
Topic archived. No new replies allowed.