-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdll1.c
95 lines (60 loc) · 1.83 KB
/
dll1.c
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/* dll1.c
Example dll using functions/datafields of main
main_export and i1TestMain must be imported from main-exe.
*/
#if defined _MSC_VER || __MINGW64__
#include <windows.h>
#endif
// set export " __declspec(dllexport)" or ""
#if defined _MSC_VER || __MINGW64__
#define export __declspec(dllexport)
#else
#define export
#endif
// set import " __declspec(dllimport)" or "extern"
#if defined _MSC_VER || __MINGW64__
#define import __declspec(dllimport)
#else
#define import extern
#endif
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
//----------------------------------------------------------------
// EXPORTS to main-module
export int dll_main_start ();
export int dll_main_exit ();
//----------------------------------------------------------------
// IMPORTS from main-module
import int i1TestMain;
import int main_export (char *);
//----------------------------------------------------------------
static int dll_i1 = 0;
//================================================================
int dll_main_start () {
//================================================================
// init plugin; use functions,variables of main
printf("\n.. dll.. dll_main_start ..\n");
// disp var of main-module
printf(" i1TestMain = %d dll_i1=%d\n",i1TestMain,dll_i1);
++i1TestMain;
++dll_i1;
// call func in main-module
main_export ("dll_main_start 1");
printf("\n");
return 0;
}
//================================================================
int dll_main_exit () {
//================================================================
// do cleanup, close windows ..
// here unused
printf("\n.. dll.. dll_main_exit ..\n");
// disp var of main-module
printf(" i1TestMain = %d dll_i1=%d\n",i1TestMain,dll_i1);
main_export ("dll_main_exit 1");
printf("\n");
return 0;
}
// eof