cginternals / libzeug

deprecated: C++ sanctuary for small but powerful and frequently required, stand alone features.
MIT License
16 stars 13 forks source link

Fix reinterpret_cast warning #85

Closed mjendruk closed 9 years ago

mjendruk commented 10 years ago

Under OS X, you get warning in ValueProperty.hpp that instead of reinterpret_cast you should use a static_cast. This is a legit warning, because is the reinterpret_cast is potentially dangerous. However, when doing so, you get an error, because you're trying to instantiate an undefined template . This errors occurs for all *.cpp files that do not include reflectionzeug/Property.h. For example ColorProperty.cpp. If you try to include reflectionzeug/Property.h you get an error that you're trying to inherit from an undefined class. The following image illustrates the problem and shows to possible fixes. I prefer #2: drawing1-3 The problem with approach #2 is that adding own properties gets even more difficult because you would also have to implement the accept() method on your own for each property. I would like to use macros for this, so we could also hide the constructor forwarding. What do you think?

scheibel commented 10 years ago

I think the problem is, that you actually want to use a dynamic cast. Both static and reinterpret casts are dangerous here as both assume that the Property is the first superclass.

mjendruk commented 10 years ago

Hm, you maybe right. Anyway, it doesn't change the problem.