tags:

views:

171

answers:

7

After a break from the language, I'm about to start a new C++ project (OpenGL). My last experience with C++ has been painful partly due to using a wrong subset of its features.

I could go out and discover the "good parts" of C++ the hard way, through experience, but I'd much rather follow a style guide such as this one from Google: http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml

Are there any other established C++ style guides out there?
Are there any particular to OpenGL or game development?

If I had to start today, the toolkit that I'd use is this: C part of C++, classes, STL for data structures, and possibly boost for what I can't find in STL. Is this enough to go by? Are there any tips or tricks to keep myself in check (compiler flags for ex.)?

+2  A: 

You already mentioned Boost, but make sure you consistently use smart pointers from the beginning. This really helps to avoid the most frequent memory management bugs and simplifies the code.

Adam Byrtek
+3  A: 

I strongly advise you to adopt RAII wherever you can. It will make dealing with exceptions easy and will save you a lot of pain with resources/memory leaks.

Matteo Italia
+6  A: 

You could checkout Exceptional C++ style, but I would perhaps start with Effective C++. Herb Sutter and Scott Meyers come highly recommended.

srean
+3  A: 

Google's code guide is ok, except for some really strange things :

  1. c++ without exceptions is not a c++.
  2. why not use auto_ptr???

Just find on the net code guidelines you like, and stick to them.

VJo
+1  A: 

C++ Coding Standards: 101 Rules, Guidelines, and Best Practices [Paperback] Herb Sutter (Author), Andrei Alexandrescu (Author)

ArunSaha
+1  A: 

I too don't particularly agree with enough of google's standards.

This may be what you're looking for, or at least help you on your way:

THE PROGRAMMING RESEARCH GROUP: HIGH·INTEGRITY C++ CODING STANDARD MANUAL

http://www.codingstandard.com/HICPPCM/index.html

it is available in html and pdf.

it's good to choose which practices you prefer, and why they are important to your project early on since programs will be written with the expectation that the available feature set/libraries is (largely) specified.

Justin
+1  A: 

List of multiple coding standards from C++ FAQ

ArunSaha
Great link. This will be a good place to start to see what's out there. Thank you.
Nick