# Wednesday, October 03, 2007

Don't include Windows.h -  I had to say it.  ;)

Always have a blank line at the bottom of each source or header file.  You get g++ compiler warnings if files don't have an extra carriage return at the bottom.

Compiler pragma warning disable statements should be ifdef'd for WIN32 only.

#include statements must match the case of the header file name.

#include "gpireader.h" // won't compile on g++, but

#include "GPIReader.h" // will compile on g++

 

Don't forget to use virtual destructors where appropriate, g++ will complain if they're missing.

Don't memset STL strings (std::string) to zeros.  Strange and odd memory corruption will occur if you do.

Don't memset structs which contain STL strings, see point above.

Don't include enum names. 

if (res == ResourceType::AccessBlock) // won't compile on g++, but

if (res == AccessBlock) // will compile on g++

 

Don't include the class prefix in header files for method declarations.

std::string GPIReader::GetXMLStringResource(ResourceType type);  // won't compile on g++, but

std::string GetXMLStringResource(ResourceType type); // will compile on g++

 

stricmp (case insensitive strcmp) function is not available on Linux, you must toUpper then compare or something.

C++ | Linux
Wednesday, October 03, 2007 6:07:53 PM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  | 
# Wednesday, June 26, 0002
I just relearned a valuable lesson today, make sure when you are using multiple libraries in your C++ project, that they all use the same runtime library.  For instance, if you have one library set to use the Multi-threaded (/MT) runtime library, then make sure the consuming project also is set to use the Multi-threaded (/MT) runtime library.

C++
Wednesday, June 26, 0002 4:23:25 PM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  |