0

Hello friends,

Suppose I want to write a dll file with MS-VC8.0 compiler. I need to add __declspec(dllexport) for all of the functions which will be called from outside of that dll.
Now my question is that whether it is possible to export all functions of that dll at a time, ie, without writing __declspec(dllexport) for all of the functions.

Thanx,
Amit

3
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by twomers
0

As far as I know, you have to put it before every function. I suppose you could save yourself a few keystrokes by doing this though.

#define DLLEXP __declspec( dllexport )

DLLEXP void someFunct() {
  // Code here
}
0

I think williamhemsworth's right, but I think you can export all members of a class in one swoop:

dll.h

#include <iostream>

#ifdef TWOMERS_BUILD_DLL
  #define TWOMERS_EXPORT __declspec(dllexport)
#else
  #define TWOMERS_EXPORT __declspec(dllimport)
#endif

class TWOMERS_EXPORT myClass {
  private:
    int thing;

  public:
    int returnThing();
    void setThing(int _thing);
};

dll.cpp:

#include "dll.h"

#define TWOMERS_BUILD_DLL

int myClass::returnThing() {
  return thing;
}
void myClass::setThing(int _thing) {
  thing = _thing;
}

Might be worth wrapping functions in a class if you want to save yourself some typing. Otherwise bite the bullet.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.