views:

170

answers:

2

Hi all -

I have the following static function:

static inline HandVal
              StdDeck_StdRules_EVAL_N( StdDeck_CardMask cards, int n_cards )

Can I export this function in a DLL? If so, how?

Thanks,

Mike

Background information:

I'm doing this because the original source code came with a VS project designed to compile as a static (.lib) library. In order to use ctypes/Python, I'm converting the project to a DLL.

I started a VS project as a DLL and imported the original source code. The project builds into a DLL, but none of the functions (including functions such as the one listed above) are exported (as confirmed by both the absence of dllexport in the source code and tools such as DLL Export Viewer). I tried to follow the general advice here (create an exportable wrapper function within the header) to no avail...functions still don't appear to be exported.

+2  A: 

You may not export that function from a DLL. static functions are equivalent to private to that file.

You can create a method in the file that calls it and export that.

Romain Hippeau
Worked, thanks.
MikeRand
+1  A: 

By defining a function with static and inline you are effectively guaranteeing that it will be only in the modules that includes the definition.

Either edit each file to remove the static inline (which might break) or change everything to use a PreProcessor directive that will allow you to have either:

#define MYAPI static inline

or

#define MYAPI __declspec(dllexport)

and then

MYAPI HandVal StdDeck_StdRules_EVAL_N( StdDeck_CardMask cards, int n_cards )

or build a set of wrappers as a seperate module which does

__declspec(dllexport) HandVal Public_StdDeck_StdRules_EVAL_N( StdDeck_CardMask cards, int n_cards )
{
     return StdDeck_StdRules_EVAL_N(cards, n_cards);
}
Richard Harrison