Skip to content

Commit 25590ad

Browse files
committed
dllexport
1 parent 3bee356 commit 25590ad

1 file changed

Lines changed: 44 additions & 32 deletions

File tree

tinyfiledialogs.h

Lines changed: 44 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,18 @@ misrepresented as being the original software.
6262
#ifndef TINYFILEDIALOGS_H
6363
#define TINYFILEDIALOGS_H
6464

65+
#ifndef TINYFD_EXTERN
66+
#if defined(_WIN32)
67+
#if defined(TINYFD_STATIC)
68+
#define TINYFD_EXTERN extern
69+
#else
70+
#define TINYFD_EXTERN __declspec(dllexport) extern
71+
#endif
72+
#else
73+
#define TINYFD_EXTERN extern
74+
#endif
75+
#endif
76+
6577
#ifdef __cplusplus
6678
extern "C" {
6779
#endif
@@ -72,40 +84,40 @@ extern "C" {
7284
#ifdef _WIN32
7385
/* On windows, if you want to use UTF-8 ( instead of the UTF-16/wchar_t functions at the end of this file )
7486
Make sure your code is really prepared for UTF-8 (on windows, functions like fopen() expect MBCS and not UTF-8) */
75-
extern int tinyfd_winUtf8; /* on windows char strings can be 1:UTF-8(default) or 0:MBCS */
87+
TINYFD_EXTERN int tinyfd_winUtf8; /* on windows char strings can be 1:UTF-8(default) or 0:MBCS */
7688
/* for MBCS change this to 0, in tinyfiledialogs.c or in your code */
7789

7890
/* Here are some functions to help you convert between UTF-16 UTF-8 MBSC */
79-
char * tinyfd_utf8toMbcs(char const * aUtf8string);
80-
char * tinyfd_utf16toMbcs(wchar_t const * aUtf16string);
81-
wchar_t * tinyfd_mbcsTo16(char const * aMbcsString);
82-
char * tinyfd_mbcsTo8(char const * aMbcsString);
83-
wchar_t * tinyfd_utf8to16(char const * aUtf8string);
84-
char * tinyfd_utf16to8(wchar_t const * aUtf16string);
91+
TINYFD_EXTERN char * tinyfd_utf8toMbcs(char const * aUtf8string);
92+
TINYFD_EXTERN char * tinyfd_utf16toMbcs(wchar_t const * aUtf16string);
93+
TINYFD_EXTERN wchar_t * tinyfd_mbcsTo16(char const * aMbcsString);
94+
TINYFD_EXTERN char * tinyfd_mbcsTo8(char const * aMbcsString);
95+
TINYFD_EXTERN wchar_t * tinyfd_utf8to16(char const * aUtf8string);
96+
TINYFD_EXTERN char * tinyfd_utf16to8(wchar_t const * aUtf16string);
8597
#endif
8698
/******************************************************************************************************/
8799
/******************************************************************************************************/
88100
/******************************************************************************************************/
89101

90102
/************* 3 funtions for C# (you don't need this in C or C++) : */
91-
char const * tinyfd_getGlobalChar(char const * aCharVariableName); /* returns NULL on error */
92-
int tinyfd_getGlobalInt(char const * aIntVariableName); /* returns -1 on error */
93-
int tinyfd_setGlobalInt(char const * aIntVariableName, int aValue); /* returns -1 on error */
103+
TINYFD_EXTERN char const * tinyfd_getGlobalChar(char const * aCharVariableName); /* returns NULL on error */
104+
TINYFD_EXTERN int tinyfd_getGlobalInt(char const * aIntVariableName); /* returns -1 on error */
105+
TINYFD_EXTERN int tinyfd_setGlobalInt(char const * aIntVariableName, int aValue); /* returns -1 on error */
94106
/* aCharVariableName: "tinyfd_version" "tinyfd_needs" "tinyfd_response"
95107
aIntVariableName : "tinyfd_verbose" "tinyfd_silent" "tinyfd_allowCursesDialogs"
96108
"tinyfd_forceConsole" "tinyfd_assumeGraphicDisplay" "tinyfd_winUtf8"
97109
**************/
98110

99-
extern char tinyfd_version[8]; /* contains tinyfd current version number */
100-
extern char tinyfd_needs[]; /* info about requirements */
101-
extern int tinyfd_verbose; /* 0 (default) or 1 : on unix, prints the command line calls */
102-
extern int tinyfd_silent; /* 1 (default) or 0 : on unix, hide errors and warnings from called dialogs */
111+
TINYFD_EXTERN char tinyfd_version[8]; /* contains tinyfd current version number */
112+
TINYFD_EXTERN char tinyfd_needs[]; /* info about requirements */
113+
TINYFD_EXTERN int tinyfd_verbose; /* 0 (default) or 1 : on unix, prints the command line calls */
114+
TINYFD_EXTERN int tinyfd_silent; /* 1 (default) or 0 : on unix, hide errors and warnings from called dialogs */
103115

104116
/** Curses dialogs are difficult to use and counter-intuitive.
105117
On windows they are only ascii and still uses the unix backslash ! **/
106-
extern int tinyfd_allowCursesDialogs; /* 0 (default) or 1 */
118+
TINYFD_EXTERN int tinyfd_allowCursesDialogs; /* 0 (default) or 1 */
107119

108-
extern int tinyfd_forceConsole; /* 0 (default) or 1 */
120+
TINYFD_EXTERN int tinyfd_forceConsole; /* 0 (default) or 1 */
109121
/* for unix & windows: 0 (graphic mode) or 1 (console mode).
110122
0: try to use a graphic solution, if it fails then it uses console mode.
111123
1: forces all dialogs into console mode even when an X server is present.
@@ -116,7 +128,7 @@ extern int tinyfd_forceConsole; /* 0 (default) or 1 */
116128
/* some systems don't set the environment variable DISPLAY even when a graphic display is present.
117129
set this to 1 to tell tinyfiledialogs to assume the existence of a graphic display */
118130

119-
extern char tinyfd_response[1024];
131+
TINYFD_EXTERN char tinyfd_response[1024];
120132
/* if you pass "tinyfd_query" as aTitle,
121133
the functions will not display the dialogs
122134
but will return 0 for console mode, 1 for graphic mode.
@@ -129,37 +141,37 @@ for graphic mode:
129141
for console mode:
130142
dialog whiptail basicinput no_solution */
131143

132-
void tinyfd_beep(void);
144+
TINYFD_EXTERN void tinyfd_beep(void);
133145

134-
int tinyfd_notifyPopup(
146+
TINYFD_EXTERN int tinyfd_notifyPopup(
135147
char const * aTitle, /* NULL or "" */
136148
char const * aMessage, /* NULL or "" may contain \n \t */
137149
char const * aIconType); /* "info" "warning" "error" */
138150
/* return has only meaning for tinyfd_query */
139151

140-
int tinyfd_messageBox(
152+
TINYFD_EXTERN int tinyfd_messageBox(
141153
char const * aTitle , /* NULL or "" */
142154
char const * aMessage , /* NULL or "" may contain \n \t */
143155
char const * aDialogType , /* "ok" "okcancel" "yesno" "yesnocancel" */
144156
char const * aIconType , /* "info" "warning" "error" "question" */
145157
int aDefaultButton ) ;
146158
/* 0 for cancel/no , 1 for ok/yes , 2 for no in yesnocancel */
147159

148-
char * tinyfd_inputBox(
160+
TINYFD_EXTERN char * tinyfd_inputBox(
149161
char const * aTitle , /* NULL or "" */
150162
char const * aMessage , /* NULL or "" (\n and \t have no effect) */
151163
char const * aDefaultInput ) ; /* NULL = passwordBox, "" = inputbox */
152164
/* returns NULL on cancel */
153165

154-
char * tinyfd_saveFileDialog(
166+
TINYFD_EXTERN char * tinyfd_saveFileDialog(
155167
char const * aTitle , /* NULL or "" */
156168
char const * aDefaultPathAndOrFile , /* NULL or "" , ends with / to set only a directory */
157169
int aNumOfFilterPatterns , /* 0 (1 in the following example) */
158170
char const * const * aFilterPatterns , /* NULL or char const * lFilterPatterns[1]={"*.txt"} */
159171
char const * aSingleFilterDescription ) ; /* NULL or "text files" */
160172
/* returns NULL on cancel */
161173

162-
char * tinyfd_openFileDialog(
174+
TINYFD_EXTERN char * tinyfd_openFileDialog(
163175
char const * aTitle, /* NULL or "" */
164176
char const * aDefaultPathAndOrFile, /* NULL or "" , ends with / to set only a directory */
165177
int aNumOfFilterPatterns , /* 0 (2 in the following example) */
@@ -169,12 +181,12 @@ char * tinyfd_openFileDialog(
169181
/* in case of multiple files, the separator is | */
170182
/* returns NULL on cancel */
171183

172-
char * tinyfd_selectFolderDialog(
184+
TINYFD_EXTERN char * tinyfd_selectFolderDialog(
173185
char const * aTitle, /* NULL or "" */
174186
char const * aDefaultPath); /* NULL or "" */
175187
/* returns NULL on cancel */
176188

177-
char * tinyfd_colorChooser(
189+
TINYFD_EXTERN char * tinyfd_colorChooser(
178190
char const * aTitle, /* NULL or "" */
179191
char const * aDefaultHexRGB, /* NULL or "" or "#FF0000" */
180192
unsigned char const aDefaultRGB[3] , /* unsigned char lDefaultRGB[3] = { 0 , 128 , 255 }; */
@@ -190,13 +202,13 @@ char * tinyfd_colorChooser(
190202
#ifdef _WIN32
191203

192204
/* windows only - utf-16 version */
193-
int tinyfd_notifyPopupW(
205+
TINYFD_EXTERN int tinyfd_notifyPopupW(
194206
wchar_t const * aTitle, /* NULL or L"" */
195207
wchar_t const * aMessage, /* NULL or L"" may contain \n \t */
196208
wchar_t const * aIconType); /* L"info" L"warning" L"error" */
197209

198210
/* windows only - utf-16 version */
199-
int tinyfd_messageBoxW(
211+
TINYFD_EXTERN int tinyfd_messageBoxW(
200212
wchar_t const * aTitle, /* NULL or L"" */
201213
wchar_t const * aMessage, /* NULL or L"" may contain \n \t */
202214
wchar_t const * aDialogType, /* L"ok" L"okcancel" L"yesno" */
@@ -205,13 +217,13 @@ int tinyfd_messageBoxW(
205217
/* returns 0 for cancel/no , 1 for ok/yes */
206218

207219
/* windows only - utf-16 version */
208-
wchar_t * tinyfd_inputBoxW(
220+
TINYFD_EXTERN wchar_t * tinyfd_inputBoxW(
209221
wchar_t const * aTitle, /* NULL or L"" */
210222
wchar_t const * aMessage, /* NULL or L"" (\n nor \t not respected) */
211223
wchar_t const * aDefaultInput); /* NULL passwordBox, L"" inputbox */
212224

213225
/* windows only - utf-16 version */
214-
wchar_t * tinyfd_saveFileDialogW(
226+
TINYFD_EXTERN wchar_t * tinyfd_saveFileDialogW(
215227
wchar_t const * aTitle, /* NULL or L"" */
216228
wchar_t const * aDefaultPathAndOrFile, /* NULL or L"" , ends with / to set only a directory */
217229
int aNumOfFilterPatterns, /* 0 (1 in the following example) */
@@ -220,7 +232,7 @@ wchar_t * tinyfd_saveFileDialogW(
220232
/* returns NULL on cancel */
221233

222234
/* windows only - utf-16 version */
223-
wchar_t * tinyfd_openFileDialogW(
235+
TINYFD_EXTERN wchar_t * tinyfd_openFileDialogW(
224236
wchar_t const * aTitle, /* NULL or L"" */
225237
wchar_t const * aDefaultPathAndOrFile, /* NULL or L"" , ends with / to set only a directory */
226238
int aNumOfFilterPatterns , /* 0 (2 in the following example) */
@@ -231,13 +243,13 @@ wchar_t * tinyfd_openFileDialogW(
231243
/* returns NULL on cancel */
232244

233245
/* windows only - utf-16 version */
234-
wchar_t * tinyfd_selectFolderDialogW(
246+
TINYFD_EXTERN wchar_t * tinyfd_selectFolderDialogW(
235247
wchar_t const * aTitle, /* NULL or L"" */
236248
wchar_t const * aDefaultPath); /* NULL or L"" */
237249
/* returns NULL on cancel */
238250

239251
/* windows only - utf-16 version */
240-
wchar_t * tinyfd_colorChooserW(
252+
TINYFD_EXTERN wchar_t * tinyfd_colorChooserW(
241253
wchar_t const * aTitle, /* NULL or L"" */
242254
wchar_t const * aDefaultHexRGB, /* NULL or L"#FF0000" */
243255
unsigned char const aDefaultRGB[3], /* unsigned char lDefaultRGB[3] = { 0 , 128 , 255 }; */

0 commit comments

Comments
 (0)