Jump to content
  • Advertisement
Sign in to follow this  
  • entries
    195
  • comments
    198
  • views
    104382

Rant mode on.

Sign in to follow this  
SiCrane

118 views

One lesser known detail about the C and C++ languages is that assert.h and its analogue cassert can both be included multiple times in the same program, and the value of the assert() macro can be potentially different after each inclusion. This just pisses me off. I understand the reasoning behind why it's been standardized this way, but it's annoying (and for the large part I don't buy it). If you use your own custom assert macro and any external headers include assert.h or cassert, your custom assert could be clobbered. Basically, it's a side effect of one of the evils of the pre-processor.

boost used to be really bad about this, but a while ago, they introduced a layer of indirection between the libraries and the assert functionality. Of course, as I write this not all of boost's libraries actually use it instead of cassert. Fortunately, boost's code is completely open so it's possible to modify the offending headers to use boost/assert.hpp instead of cassert, and BOOST_ASSERT() instead of assert(). This reduces the number of annoyances. Of course a simpler method is just to comment out the assert includes and remember to include your own assert macro before any boost headers.

Then some libraries don't even make that much of an attempt.

It's sufficiently bad that my makefiles eventually all start sprouting cpp -dI rules so I can track down offending header files.
Sign in to follow this  


0 Comments


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!