C++ gcc vs visual c++ -
hello starting programmer in c++ looking differences in compilers imported same source files both gcc compiler (code blocks) , visual c++ (visual studio express) , found strange behavior did not expect.
the visual c++ threw bunch of errors in opinion quite big... iterating through vector different iterators , iterator instance of vector operation done on iterator.... gcc compiled , threw no errors in runtime... while visual c++ threw bunch of errors in compilation , threw runtime error of 'different iterator type', or dynamic char allocation new char[str.length()+1] , strcpy_s() them string - visual c++ debuger threw runtime error of corrupted heap while code blocks debugger ran fine.
my question is. there big of difference in these compilers , debuggers? should worry programming on bad level if code runs totally perfect gcc , code blocks debuger throws errors in visual studio?
i ve learned programm in c++ in code blocks, visal c++ has shown me mistakes totally not aware of..
the problem code, not compilers or setup. types of problems describing examples of undefined behaviour result rather bad programming or coding techniques (in fact, of them hard achieve, without going out of way write flawed code).
the thing is, compilers not required detect such things. whether or not concern of compiler or library quality of implementation. in case, appears version of vc++ detecting concerns g++ not, point in favour of vc++.
my experience reverse of that: find g++ detects more problems vc++. however, both vc++ , g++ diagnose problems other not.
which goes show milage vary. personally, i'm advocate of feeding code through multiple compilers when possible - precisely because widens net of problems diagnosed.
and exercise policy of ensuring code compiles cleanly compilers (no warnings or diagnostics) without having disable diagnostics, , avoiding use of code constructs designed suppress compiler diagnostics.
one thing realise compilers, when installed, typically configured not produce many diagnostics. reasons historical. necessary turn on settings make compiler give warnings or errors. g++, command options -wall -pendantic (which can enabled through code::blocks) increase number of problems reported. there similar options vc++ (although don't remember them offhand).
Comments
Post a Comment