Reputation: 163
I am using two different c++ libraries. Both libraries use a name for a type, let's say, called fofo. In lib1.h:
typedef short fofo;
In lib2.h:
namespace LIB2
{
typedef struct
{
uint16_t toto;
} fofo;
}
using LIB2::fofo;
I have a C++ project/VS 2008 that uses both libraries: when I do in my project
#include lib1.h
I get the error: error C2874: using-declaration causes a multiple declaration
I would like to use in my project both libraries but without making any change to these libraries. The only thing that I can modify is my VS2008 project. Thanks for your help!
Upvotes: 4
Views: 1521
Reputation: 3929
this (dirty) workaround will probably work (depending how the headers are being used)
instead of including lib1.h directly ,wrap it by making a new headerfile
lib1wrapped.h
#define fofo fofo_wrap
#include "lib1.h" // OR <lib1.h>
#undef fofo
Upvotes: 4