Very interesting language, spotted when looking for Vala (generates C code) -)
http://nimrod-code.org/index.html
Wednesday, May 23, 2012
Tuesday, May 22, 2012
Monday, May 14, 2012
Dangerous C++ preprocessor
It took me three weeks to find this mistake in a huge code base. Program suddenly crashes after the changes that look obviously innocent. And the root of all evil was not memory leaks or so but the #ifdef.
header.h
struct mystruct : somebasestruct {
mystruct();
#ifdef FEATURE_X
int somefield;
#endif
};
module1.cpp
#include ....
#include "header.h"
sizeof(mystruct) = 8
module2.cpp
#include ....
#include "header.h"
sizeof(mystruct) = 4
And guess why? Yes, check building settings, what is defined or not...
header.h
struct mystruct : somebasestruct {
mystruct();
#ifdef FEATURE_X
int somefield;
#endif
};
module1.cpp
#include ....
#include "header.h"
sizeof(mystruct) = 8
module2.cpp
#include ....
#include "header.h"
sizeof(mystruct) = 4
And guess why? Yes, check building settings, what is defined or not...
Subscribe to:
Posts (Atom)