diff options
| author | grischka <grischka> | 2017-04-04 08:34:52 +0200 |
|---|---|---|
| committer | grischka <grischka> | 2017-04-04 08:34:52 +0200 |
| commit | 536ed76d5a69d8e3c0e247d6557f5942818cb253 (patch) | |
| tree | d3cf8de45fcc8493fb7f9acd5239e63ec4a7b92e /win32 | |
| parent | c4c3f5009e086b2eca472f61b99da1ade6d33286 (diff) | |
| download | tinycc-536ed76d5a69d8e3c0e247d6557f5942818cb253.tar.gz tinycc-536ed76d5a69d8e3c0e247d6557f5942818cb253.tar.bz2 | |
tccgen/win32: let __declspec(dllimport) imply extern
Also, retain storage qualifiers in type_decl, in particular
also for function pointers. This allows to get rid of this
very early hack in decl()
type.t |= (btype.t & VT_STATIC); /* Retain "static". */
which was to fix the case of
int main() { static int (*foo)(); ...
Also:
- missing __declspec(dllimport) is an error now
- except if the symbol is "_imp__symbol"
- demonstrate export/import of data in the dll example (while
'extern' isn't strictly required with dllimport anymore)
- new function 'patch_storage()' replaces 'weaken_symbol()'
and 'apply_visibility()'
- new function 'update_storage()' applies storage attributes
to Elf symbols.
- put_extern_sym/2 accepts new pseudo section SECTION_COMMON
- add -Wl,-export-all-symbols as alias for -rdynamic
- add -Wl,-subsystem=windows for mingw compatibility
- redefinition of 'sym' error for initialized global data
Diffstat (limited to 'win32')
| -rw-r--r-- | win32/examples/dll.c | 7 | ||||
| -rw-r--r-- | win32/examples/hello_dll.c | 17 |
2 files changed, 13 insertions, 11 deletions
diff --git a/win32/examples/dll.c b/win32/examples/dll.c index 4c1d8ce..052a056 100644 --- a/win32/examples/dll.c +++ b/win32/examples/dll.c @@ -4,9 +4,10 @@ // #include <windows.h> -#define DLL_EXPORT __declspec(dllexport) -DLL_EXPORT void HelloWorld (void) +__declspec(dllexport) const char *hello_data = "(not set)"; + +__declspec(dllexport) void hello_func (void) { - MessageBox (0, "Hello World!", "From DLL", MB_ICONINFORMATION); + MessageBox (0, hello_data, "From DLL", MB_ICONINFORMATION); } diff --git a/win32/examples/hello_dll.c b/win32/examples/hello_dll.c index 7adba77..4813c5b 100644 --- a/win32/examples/hello_dll.c +++ b/win32/examples/hello_dll.c @@ -5,15 +5,16 @@ #include <windows.h> -void HelloWorld (void); +void hello_func (void); +__declspec(dllimport) extern const char *hello_data; int WINAPI WinMain( - HINSTANCE hInstance, - HINSTANCE hPrevInstance, - LPSTR lpCmdLine, - int nCmdShow) + HINSTANCE hInstance, + HINSTANCE hPrevInstance, + LPSTR lpCmdLine, + int nCmdShow) { - HelloWorld(); - return 0; + hello_data = "Hello World!"; + hello_func(); + return 0; } - |
