Questions tagged [declspec]

67 questions
3
votes
1 answer

__declspec(align) for multiple declarations

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))…
Rotem
  • 21,452
  • 6
  • 62
  • 109
3
votes
0 answers

What is the need for dllimport?

I am playing with DLLs to get a better understanding of them. So I created a simple dll (with load-time dynamic linking) which has functions to Add, Sub and Mul. In the header file for the dll I used __declspec(dllexport) for the function…
Harsha
  • 263
  • 1
  • 3
  • 14
2
votes
1 answer

Using __declspec(nothrow) on functions that return references

I'd like to apply __declspec(nothrow) on some of my member functions that return object references. For example, I'd like to add it to this function (in MyClass.h): CMyClass& operator= ( IN UInt32 nValue ) { return ( SetValue ( nValue )…
xxbbcc
  • 16,930
  • 5
  • 50
  • 83
2
votes
2 answers

Do overloaded operators within classes require __declspec(dllexport) if they're used in a DLL project?

When using __declspec(dllexport), should overloaded operators also have this exportation flag assigned? For example, say you have something like: /* Overloaded operator (equivalent operator) returns true if x equals compared…
Darkenor
  • 4,349
  • 8
  • 40
  • 67
2
votes
0 answers

__declspec(dllimport) c structure: access violation

For some time I have been trying to find a solution for the below problem, but with no success: I have a "c" dll, where the following structure is defined: file: myDll.h #ifdef EXPORTS #define EXPORT __declspec(dllexport) #else #define EXPORT…
test_c
  • 21
  • 1
2
votes
1 answer

What does "storage-class information" mean in __declspec()?

I am reading the MSDN article about __declspec. It starts with: The extended attribute syntax for specifying storage-class information uses the __declspec keyword, which specifies that an instance of a given type is to be stored with a…
smwikipedia
  • 61,609
  • 92
  • 309
  • 482
1
vote
1 answer

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

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…
xxbbcc
  • 16,930
  • 5
  • 50
  • 83
1
vote
2 answers

LNK2001 unresolved external when importing functions from MFC DLL

I have created an MFC DLL and have exported the functions for example in the file SerialPort.h: class CSerialPortApp : public CWinApp { public: CSerialPortApp(); __declspec(dllexport) int SWrite(unsigned char* toSend, int len); }; and in…
Lee Worbey
  • 85
  • 1
  • 10
1
vote
1 answer

Is there a way to avoid redefining boilerplate macros for shared library export attributes in every source file when using CMake?

So I've been working on porting a CMake C++ to building on Windows using Visual Studio. I've learned that, unlike Linux/g++ which exports all symbols automatically, that MSVC does not export any symbols that it is not explicitly told to do so. …
Chris Gnam
  • 311
  • 2
  • 7
1
vote
1 answer

MSVC: __declspec(dllexport) does not symbols

I have a small issue when it comes to writing a DLL in MSVC (the 2010 version in particular). My program consists of the main part and a DLL. The DLL contains a function that is __declspec(dllexport) int test_function(void) { return 42; } The…
asiouser
  • 241
  • 1
  • 3
  • 5
1
vote
2 answers

How to hide some class public properties from watch list?

I am still using BDS2006 (Turbo explorer C++) and upgrading is still not an option. I have a problem that while debugging some of more advanced template/classes containing properties like: __declspec( property (get=???, put=???) ) ??? ???; are…
Spektre
  • 49,595
  • 11
  • 110
  • 380
1
vote
1 answer

Call C++ function from inside dynamically loaded dll

I'm writing a C++ programm that dynamically loads a dll at runtime and calls a function within that dll. Thats working fine but now i want to call a function defined in my C++ programm from within the dll. My main.cpp looks like this: #include…
Painkiller
  • 115
  • 9
1
vote
1 answer

Using dllimport in place of dllexport

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…
eball
  • 105
  • 5
1
vote
2 answers

Pros and Cons of Using .def Files

I don't understand this paragraph : Exporting functions in a .def file gives you control over the export ordinals. When you add an exported function to your DLL, you can assign it a higher ordinal value than any other exported function. When you do…
user5708257
1
vote
0 answers

__declspec(dllimport) not behaving as expected

I am using this code here : include "windows.h" #include "stdio.h" #include #pragma comment(lib, "StubDLL.lib") // StubDLL defines as __declspec(dllexport) Add and Function #include "StubDLL.h" // just to try it with MS…
n80fr1n60
  • 701
  • 1
  • 6
  • 12