Questions tagged [declspec]

67 questions
107
votes
4 answers

what does __declspec(dllimport) really mean?

I saw the Qt source code like this: class Q_CORE_EXPORT QBasicAtomicInt { public: ... }; Which Q_CORE_EXPORT macro defines like below: define Q_DECL_IMPORT __declspec(dllimport) So what does __declspec(dllimport) really mean?
gemfield
  • 3,228
  • 7
  • 27
  • 28
23
votes
2 answers

Proper way to link static libraries with dll

My project builds through few static libraries which should linked to main dll library gain one single dll as a result. Using __declspec(dllexport) attribute does not lead to appearance of specified functions of static libraries to dll, libraries…
triclosan
  • 5,578
  • 6
  • 26
  • 50
12
votes
2 answers

How does `__declspec(align(#))` work?

Yes, I have read this: http://msdn.microsoft.com/en-us/library/83ythb65.aspx But it's not clear to me. First of all, __declspec(align(#)) makes every object (in a structure) declared with it start at an aligned offset. That part is clear. The…
NPS
  • 6,003
  • 11
  • 53
  • 90
8
votes
1 answer

Windows export/import symbols under MinGW vs MSVS; CMake's WINDOWS_EXPORT_ALL_SYMBOLS ignored

To build a C library with Visual Studio, the CMake command set(WINDOWS_EXPORT_ALL_SYMBOLS ON) saves me from adding __declspec(dllexport) or __declspec(dllimport) in front of function declarations; explicit import/export symbols are only required…
Joachim W
  • 7,290
  • 5
  • 31
  • 59
8
votes
1 answer

C/C++ linkage convention

When calling C++ algorithms like copy_if, transform etc which take a unary or binary function as the last argument, can I pass a C library function like atoi or tolower. For e.g. below calls work fine and give the correct output (tried in ideone) 1)…
irappa
  • 749
  • 4
  • 11
7
votes
1 answer

C++ [[gnu::visibility("default")]] vs __declspec(dllexport) on Windows and Linux

I needed to make some shared libraries in C++ and I used linux as my developer operating system. I know that I need to make symbols visible if I want to load them via dlsym/LoadLibrary. So in linux all of my symbols followed this pattern: extern "C"…
Szőke Szabolcs
  • 511
  • 7
  • 19
6
votes
2 answers

What does __declspec(uuid(" ComObjectGUID ")) expand to?

I have a piece of code that uses Microsoft-specific extension to the C++: interface __declspec(uuid("F614FB00-6702-11d4-B0B7-0050BABFC904")) ICalculator : public IUnknown { //... }; What does this sentence expand to? How can I rewrite it with…
ezpresso
  • 7,896
  • 13
  • 62
  • 94
5
votes
2 answers

C - __declspec(thread) variables performances

I'm working on the multithreading implementation of a library. In one module of this library there are some global variables (very often used in the program execution). In order to make the access to those variables more safe, I declared them using…
Beppe
  • 381
  • 2
  • 7
  • 15
4
votes
3 answers

__declspec(dllexport) ::vector

I've been trying to work out how to return an array of strings from a c++ dll to a c# application but am stuck on how to do this or find an article at a very basic level. Suppose I have the code below. How do I fix the bolded line: extern "C" { …
mattpm
  • 1,310
  • 2
  • 19
  • 26
4
votes
1 answer

Stopping dllexport functions in .lib from getting exported from a DLL

I've got a copy of the axtls library that I've compiled into a static library. I'm linking it into a DLL that I'm building, and some of the axtls functions (_MD5_Final, _MD5_Init and _MD5_Update) seem to be getting exported from my DLL. I'm trying…
obmarg
  • 9,369
  • 36
  • 59
3
votes
3 answers

Convert __declspec in C header to Delphi

I'm having trouble converting a class from a C header to use in Delphi. A snippet of the declaration in the C header file looks like this: class __declspec(uuid("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee")) ISomeInterface { public: virtual BOOL …
petej
  • 31
  • 3
3
votes
1 answer

__declspec(dllexport) on nested classes

Code: #ifdef BUILD_DLL #define MY_API __declspec(dllexport) #else #define MY_API __declspec(dllimport) #endif class MY_API A { public: void some_method(); class B { public: void other_method(); …
kuga
  • 1,483
  • 1
  • 17
  • 38
3
votes
2 answers

Trying to compile simple dll written in C using gcc fails

Trying to compile a simple DLL written in C using gcc. Tried following many tutorials, but can't get it to compile even when I strip the file down to the very basics. test_dll.c #include __declspec(dllexport) int __stdcall hello() { …
Casperscacion
  • 33
  • 1
  • 4
3
votes
1 answer

Warning C4091: ' __declspec(dllexport)'

I have the following code where I am trying to export a function called "Interface_API" out of my dll. #ifdef INTERFACEDLL_EXPORTS #define UserApp_API __declspec(dllexport); #else #define UserApp_API __declspec(dllimport); #endif UserApp_API int…
Ela
  • 33
  • 1
  • 4
3
votes
1 answer

How to handle multiple libraries when exporting symbols?

I am working on a project (cross-platform, but only Windows matters in this case) that creates a lot of shared libraries (which are somewhat dependent of each other). All the header files that declare functions or structures/classes/enums/etc. are…
tatones
  • 81
  • 4
1
2 3 4 5