468,509 Members | 1,439 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,509 developers. It's quick & easy.

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

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
1 1417
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.

Similar topics

5 posts views Thread by Mike S. | last post: by
1 post views Thread by Steve Marsden | last post: by
13 posts views Thread by Lee Newson | last post: by
2 posts views Thread by zamir.khan | last post: by
reply views Thread by =?Utf-8?B?Y2hyaXNiZW4=?= | last post: by
3 posts views Thread by gieforce | last post: by
1 post views Thread by fmendoza | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.