Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Migration from native C++ to C++/CLI: new keywords conflict with old names

I am trying to add some CLI functions to an existing C++ library. In one of the includes a class defines

includedHeader.h:

class IncludedClass
{
    SomeType generic;
    SomeType specific;
}

This code compiles in C++, but the generic member name is now recognized as a keyword. Is there some way to disable the new sintax from parts of the code?

Edit: the compiler error are

error C2059: syntax error : 'generic'
error C2238: unexpected token(s) preceding ';' 

both referring to the line with "generic".

like image 742
Coffee on Mars Avatar asked Feb 02 '26 06:02

Coffee on Mars


1 Answers

If you are linking the compiled library, you can do something like this:

#define generic     __identifier(generic)

#include <includedHeader.h>

#undef generic
like image 195
Tayyab Akram Avatar answered Feb 03 '26 23:02

Tayyab Akram



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!