-
Notifications
You must be signed in to change notification settings - Fork 1
/
library_attach.cpp
34 lines (32 loc) · 1.05 KB
/
library_attach.cpp
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
/*
* SimpleEmbedR: A very simple demonstration wrapper for R.
*
* Disclaimer
* ----------
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
#include <windows.h>
#include "init.h"
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
switch (ul_reason_for_call) {
case DLL_PROCESS_ATTACH:
initR();
break;
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
endR();
break;
}
return TRUE;
}
#else // not defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
#include "init.h"
void __attribute__ ((constructor)) initR(void);
void __attribute__ ((destructor)) endR(void);
#endif // not defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
// not sure what to do if not linux or windows.