I'm trying to use a third party SDK in some C++ code. While the SDK and headers are technically compatible with C++, it's really just a lump of nasty C.
In particular the main header files has many hundreds of #defines of which these are the worst.
#define C 0 //Celsius
#define F 1 //Fahrenheit
#define R 2 // Rankine
#define K 3 // Kelvin
Now, you can imagine what nice error messages I get when trying to use boost libraries that have things like this in them:
template< typename F > struct template_arity;
A few tactical #undefs could fix things, but it still feels like a ticking bomb. I could alternatively rewrite large parts of the third-party header, or maybe just try and isolate the sections I really need.
Is there any better solution to this problem?
What about only incuding the offnding files in a single .cpp file, and then just expose the functionality you need through a separate header?
Have the original author rewrite it for you?
Seriously, this looks like a case of very poor design. I'd rewrite the macros, perhaps as enum
s.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With