declspec

Using dllimport in place of dllexport

走远了吗. 提交于 2020-03-16 08:09:22
问题 I seem to be able to use __declspec(dllexport) and __declspec(dllimport) interchangeably when building my dll in Visual Studio 2015. I would have thought when making the DLL that the dllexport command would have been required but it seems either dllexport or dllimport is adequate.I have the following header file declaring a simple add() functions: add.h #pragma once #ifdef ADDDLL_EXPORTS #define ADDDLL_API __declspec(dllexport) #else #define ADDDLL_API __declspec(dllimport) #endif ADDDLL_API

Why/when is __declspec( dllimport ) not needed?

故事扮演 提交于 2019-12-27 12:17:15
问题 In a project using a server.dll and a client.exe, I have dllexport ed a server symbol from the server dll, and not dllimport ed it into the client exe. Still, the application links, and starts, without any problem. Is dllimport not needed, then??? Details: I have this 'server' dll: // server.h #ifdef SERVER_EXPORTS #define SERVER_API __declspec(dllexport) #else #define SERVER_API // =====> not using dllimport! #endif class SERVER_API CServer { static long s; public: CServer(); }; // server

__declspec(align) for multiple declarations

匆匆过客 提交于 2019-12-23 18:06:49
问题 Sorry for the very simple question, couldn't find a googleable answer. Is this declaration syntax: __declspec(align(16)) float rF[4]; __declspec(align(16)) float gF[4]; __declspec(align(16)) float bF[4]; Equivalent to this: __declspec(align(16)) float rF[4], gF[4], bF[4]; Or will only the first variable be aligned in the latter syntax? If it matters, these are local variables inside a global method. 回答1: Yes. A __declspec is part of the storage class and applies to all declarators in the

Proper way to link static libraries with dll

北城以北 提交于 2019-12-20 18:34:04
问题 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 not linked with dll at all. Then I tried to build each library as shared for getting proper names of exported functions and created .def file based on them. Using .def file leaded to result. Should __declspec(dllexport) and .def-file act equally in

VC++ 2008/2010: is throw() or __declspec(nothrow) a better choice?

℡╲_俬逩灬. 提交于 2019-12-11 08:56:20
问题 When using VC++ 2008 and 2010, which marker is better to use to indicate a function won't throw exceptions: throw() (C++ standard) __declspec(nothrow) (MS extension) I read a few older forum discussions where people said that using throw() may actually force the compiler to generate additional code to catch exceptions in case the function does throw (against the marker). Their advice is not to use throw() but use __declspec(nothrow) instead, since the compiler can actually use it for

__declspec(dllexport) ::vector<std::string>

北慕城南 提交于 2019-12-06 04:50:54
问题 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" { __declspec(dllexport) int GetANumber(); //unsure on this line: **__declspec(dllexport) ::vector<std::string> ListDevices();** } extern::vector<std::string> GetStrings() { vector<string> seqs; return seqs; } extern int GetANumber() { return 27; } thanks

Proper way to link static libraries with dll

帅比萌擦擦* 提交于 2019-12-03 05:49:17
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 not linked with dll at all. Then I tried to build each library as shared for getting proper names of exported functions and created .def file based on them. Using .def file leaded to result. Should __declspec(dllexport) and .def-file act equally in my case? Is it possible to generate a .def file from sources? Since I have C++ code I'm not able to

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

泄露秘密 提交于 2019-12-01 03:42:15
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" [[gnu::visibility("default")]] void f(); I used clang with C++11 enabled and I was able to load f in my host program. When I moved to windows I used GCC 4.8.2 with C++11 enabled and that pattern worked on windows machine too with LoadLibrary . (I needed to use C++11 for new attribute syntax). I know that on windows I need to use __declspec

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

孤人 提交于 2019-12-01 01:49:01
问题 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" [[gnu::visibility("default")]] void f(); I used clang with C++11 enabled and I was able to load f in my host program. When I moved to windows I used GCC 4.8.2 with C++11 enabled and that pattern worked on windows machine too with LoadLibrary .

Why/when is __declspec( dllimport ) not needed?

泄露秘密 提交于 2019-11-26 18:49:25
In a project using a server.dll and a client.exe, I have dllexport ed a server symbol from the server dll, and not dllimport ed it into the client exe. Still, the application links, and starts, without any problem. Is dllimport not needed, then??? Details: I have this 'server' dll: // server.h #ifdef SERVER_EXPORTS #define SERVER_API __declspec(dllexport) #else #define SERVER_API // =====> not using dllimport! #endif class SERVER_API CServer { static long s; public: CServer(); }; // server.cpp CServer::CServer(){} long CServer::s; and this client executable: #include <server.h> int main() {