Sunday 15 February 2015

visual studio 2013 - Differences between C++ compilers -



visual studio 2013 - Differences between C++ compilers -

while working on assignment info structures today, came across few errors had address new me. example, following:

struct node { // info , stuff node(const t& d = t{}, node * const p = nullptr, node * const n = nullptr, unsigned int f = 0) : data(d), prev(p), next(n), freq(f) {} // other stuff };

this ran fine in visual studio, not in g++. had alter nullptr 0, though visual studio wanted me utilize nullptr!

another incident using school's compiler gave me next message:

warning: extended initializer lists available -std=c++0x

so naturally went ahead , added makefile.

this got me wondering, how see errors result simple differences in compilers, given writing more complex programs in future? visual studio not backwards compatible older compilers? can alter settings? looking general knowledge of things should aware of when comes using various compilers.

g++ default compile in c++03 mode, c++ standard before c++11. tell g++ code in fact c++11 code, have utilize -std=c++11 compiler switch. example:

g++ -std=c++11 -o test test.cc

c++ visual-studio-2013 compilation

No comments:

Post a Comment