DLL creation, confusion with __declspec (dllexport)

Visual Studio C++ 2005
Windows XP

I am creating this DLL. The DLL is actually linking to another LIB. I included the headers and the lib path. Everything compiles fine.

Actually, I wrote this code to work on Linux, which works fine. Now I am porting it to work in windows.

However, I noticed that some DLLs from some sample code use this in the header:

static __declspec(dllexport) float some_function(int num1, int num2);

However, I made the following code example below for the * .h header file. However, not sure if I still need higher or not?

#ifdef __cplusplus
extern "C" {
#endif

media_t* get_media(media_description_t* obj);
void* get_item(media_description_list_t *obj, int num);
int get_number_format(media_t *obj);
const char* get_media_value(media_t *obj);

#ifdef __cplusplus
}
#endif

Sample code for implementing * .cpp file

int get_number_format(media_t *obj)
{
    Media *med = (Media*)obj;
    return med->getNumFormat();
}

So, do I need this static __declspec(dllexport)?

Thanks so much for any advice,

+3
source share
4 answers

, , , DLL. __declspec (dllexport) . , .def, . , . Docs .

+4

__declspec(dllexport) DLL. , , DLL, .

DLL, , , .

+2

, , dllexport, , .

+1
source

If you put the implementation of the method in the h file, you do not need to use a declaration __declspec(dllexport).

0
source

Source: https://habr.com/ru/post/1784372/


All Articles