This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: gcc can not distinguish the same file or same class with the different module or library
- From: John Love-Jensen <eljay at adobe dot com>
- To: summer xia <xiaguangt at gmail dot com>, MSX to GCC <gcc-help at gcc dot gnu dot org>, <dave dot korn at artimi dot com>, <aph-gcc at littlepinkcloud dot com>
- Date: Wed, 22 Aug 2007 07:32:33 -0500
- Subject: Re: gcc can not distinguish the same file or same class with the different module or library
Hi XiaGuangTai,
On my project, we use these tags:
// Windows using VC++
#define EXPORT __declspec(dllimport)
#define CLASS_EXPORT
NOTE: VC++ uses a "flippy" EXPORT macro. It's __declspec(dllexport) when
building the library, and __declspec(dllimport) when using the library.
// Using GCC, with visibility set to "hidden" for the project.
#define EXPORT __attribute__((visibility("default")))
#define CLASS_EXPORT __attribute__((visibility("default")))
Then we have classes like:
class CLASS_EXPORT Foo
{
public:
EXPORT Foo();
EXPORT Foo(int);
EXPORT Foo(double);
EXPORT virtual ~Foo();
};
Is that the sort of declare control you are looking for?
Side note, the CLASS_EXPORT is needed for GCC so the RTTI information is
externally visible. Otherwise you may run into problems with exception
handling and typeid.
Sincerely,
--Eljay