On Jan 21, 2:29*pm, "Łukasz Z±bik" <lza...@omnis.plwrote:
I have project that uses managed c++ where I use c - library, this library
contains some variables named generic, during compilation I get error: Error
1 error C2146: syntax error : missing ';' before identifier 'generic',
Problem is that in dotNet generic is a keyword, and I cannot change this
name becouse I have only lib file and includes.
How to solve this problem?
Are you sure that you don't mean C++/CLI?
No matter:
Add a layer of indirection (the solution to
so many software problems). Write an
ordinary C++ wrapper that avoids using
"generic" in its interface, and call the
wrapper from your "Managed C++".
ie:
library.h
---------
extern void generic(int);
wrapper.h
---------
extern void wrap_generic(int);
wrapper.cpp
-----------
#include "wrapper.h"
#include "library.h"
void wrap_generic(int x) {
generic(x);
}
managed_cpp.cpp
---------------
#if 0 // won't work
#include "library.h" // keyword - bzzt
:
generic(23); // keyword - bzzt
#endif
// this is ok
#include "wrapper.h"
:
wrap_generic(23); // fine
HTH