gcc - How to make g++ force me to adhere to C++ standard -


i trying learn c++ having no previous experience or c, , see training materials trying teach me c coding instead of c++.

as don't have enough knowledge discern if books trying teach me proper c++ or not, thought set parameter on g++ compiler save me problem. here question is:

how can set g++ compiler in windows won't compile if writing not pure c++ standard?

many in advance

how can set g++ compiler in windows won't compile if writing not pure c++ standard?

you cannot. agree of @lightness said in answer. not compiler's job warn of ways might invoking undefined behaviour (some of aren't detectable @ compile time).

however, not agree part of answer equates -wall -wextra -pedantic "warnings turned way high".

quoting gcc manuals (v5.2) on options mean, emphasis mine:

-wall

this enables all warnings constructions users consider questionable, , that easy avoid [...]

-wextra

this enables some warning flags not enabled -wall.

-pedantic

issue warnings demanded strict iso c , iso c++ [...]

not constructs "not pure c++" demand warning standard. there many things -wall -wextra -pedantic not protect from, , many things quite programming errors not covered standard (e.g. -wsign-conversion, -wswitch-default, -wlogical-op, -woverloaded-virtual...)

so recommendation here is, pick compiler manual, , check available warning options, selecting strictest set can live with. repeat process regularly.


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -