-
Notifications
You must be signed in to change notification settings - Fork 23
/
lib-export-api.h
executable file
·60 lines (46 loc) · 1.74 KB
/
lib-export-api.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//
// lib-export-api.h
// SoftMeter library
//
// Copyright © 2020 StarMessage software. All rights reserved.
// https://www.starmessagesoftware.com/softmeter
//
/*
#define USE_STDCALL_CONVENTION
#if defined( USE_STDCALL_CONVENTION) && defined( _WIN32 )
#define DLL_CALLING_CONVENTION __stdcall
#else
// this remanins as a blank define, needed for the MAC
#define DLL_CALLING_CONVENTION
#endif
*/
#ifdef __cplusplus
// extern "C" means that the function behind the descriptor
// should be compiled with the C standard naming mangling.
#define C_EXPORT extern "C"
// #define C_EXPORT
#else
#define C_EXPORT
#endif
#ifdef _WIN32
// info about _WINDLL
// https://stackoverflow.com/questions/14052944/compile-check-if-compiling-as-static-library
#ifndef _WINDLL // do not export the functions if this compilation is not for a DLL
#define EXPORT_API
#define CALL_CONV
#else
// __declspec(dllexport) adds the export directive to the object file so you do not need to use a .def file.
// When exporting functions with either method, make sure to use the __stdcall calling convention.
// To export functions, the __declspec(dllexport) keyword must appear to the left of the calling-convention keyword,
// if a keyword is specified. For example:
// __declspec(dllexport) void __cdecl Function1(void);
// or
// __declspec(dllexport) void __stdcall Function1(void);
// __declspec(dllexport) cannot be applied to a function with the __clrcall calling convention.
#define EXPORT_API C_EXPORT __declspec(dllexport)
#define CALL_CONV __stdcall
#endif
#else
#define CALL_CONV
#define EXPORT_API C_EXPORT __attribute__((visibility("default")))
#endif