The following code compiles fine on Windows with Visual Studio:
class_handle(base *ptr) : ptr_m(ptr), name_m(typeid(base).raw_name()) { signature_m = CLASS_HANDLE_SIGNATURE; }
If I try to compile the same code on Linux I get:
error: ‘const class std::type_info’ has no member named ‘raw_name’
as far as I understand, raw_name is a Microsoft specific implementation. How do I have to change my code so it compiles both on Windows and Linux systems?
EDIT1 I prefer to not modify the original code, I just need a workaround to compile with gcc. Is that possible?
EDIT2 will #define raw_name name do the trick?
Write these:
with different implementation on Windows and not-on-Windows using an
#ifdefblock on a token you know to be defined in the microsoft compiler, but not in your other compiler. This isolates the preprocessing differences between MS and non-MS compiled versions to an isolated file.This does require a minimal amount of change to the original code, but does so in a way that will still compile on the microsoft compiler.