Howto EXPORT_C const int..?

Login to reply to this topic.
Mon, 2006-03-27 13:40
Joined: 2006-03-27
Forum posts: 2
I have a Visual C++ (using Carbide.VS) problem..

This is my code, witten in a static-interface-dll:

** headerfile**
namespace x {

IMPORT_C extern const TInt8* const aaa;

}

** cpp **
namespace x {

EXPORT_C const TInt8* const aaa = (const TInt8*)("bbb");

}

With the error ->

error C2201: 'aaa' : must have external linkage in order to be exported/imported


This is working in CodeWarrior, and I cannot see what other options I have here..?

I think my code can be narrowed down to these cases ->

1)
__declspec(dllexport) int bar = 42;  // OK

2)
extern  __declspec(dllexport) const int baz;
const int baz = 42;  //OK

3)
__declspec(dllexport) const int foo = 42;  // ERROR

4)
extern  __declspec(dllexport) const int faz;
__declspec (dllexport) const int faz = 42;  // ERROR


I must be able to access "aaa" both internally and externally of this dll/lib.. my current standpoint is that this is a incompatibility issue MSVC/Carbide.VS.

Anyone who can prove me wrong?

Tue, 2006-03-28 07:25
Joined: 2006-03-27
Forum posts: 2
Re: Howto EXPORT_C const int..?
Quote from: mageriksson
I have a Visual C++ (using Carbide.VS) problem..

This is my code, witten in a static-interface-dll:
....
I must be able to access "aaa" both internally and externally of this dll/lib.. my current standpoint is that this is a incompatibility issue MSVC/Carbide.VS.

Anyone who can prove me wrong?

I quote myself.. it was shown that it didn't work in CodeWarrior either, but no warning/error is issued. I guess the only solution to this is a complete redisign, could make a #define instead.. but that is so C..  Cool
Fri, 2006-06-02 21:47
Joined: 2006-05-08
Forum posts: 162
Re: Howto EXPORT_C const int..?
I'm a bit baffled... why don't you simply declear and define the variable in the include file? In which case, any applications using it will have it by means of compilation, no need to export it.

  • Login to reply to this topic.