By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,710 Members | 1,208 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,710 IT Pros & Developers. It's quick & easy.

Problem with compiling managed c++ code with added c - library

P: n/a
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?

--
pozdrawiam Łukasz

Jan 21 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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

Jan 21 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.