Skip to content

Commit

Permalink
Fixed bug 4034 - Do we really need _DllMainCRTStartup() in every Wind…
Browse files Browse the repository at this point in the history
…ows build?

Andreas Falkenhahn

In src/SDL.c there is this code:

_DllMainCRTStartup(HANDLE hModule,

...

The comment says that this is needed on Watcom C for some reason but why is it included then when building with Visual C as well? Shouldn't it be only included when compiling on Watcom C then?

I'm asking because this code caused me a lot of headaches because I'm building a DLL that contains SDL and I link using /MT and the _DllMainCRTStartup() symbol obviously led to lots of trouble but it wasn't clear to me where the problem was because all I got from the linker was:

LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup

So I had to got through each and every object to see what the culprit was. See here for the full story:
https://stackoverflow.com/questions/25067151/lnk2019-unresolved-external-symbol-main-referenced-in-function-tmaincrtstar/48177067#48177067

So if it isn't necessary on Visual C, please just leave that symbol out on Visual C so that it no longer leads to any trouble. Thanks.
  • Loading branch information
slouken committed Feb 18, 2018
1 parent 75a5830 commit 3c9d333
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/SDL.c
Expand Up @@ -451,9 +451,7 @@ SDL_GetPlatform()
#endif
}

#if defined(__WIN32__)

#if !defined(HAVE_LIBC) || (defined(__WATCOMC__) && defined(BUILD_DLL))
#if defined(__WIN32__) && defined(__WATCOMC__) && defined(BUILD_DLL)
/* Need to include DllMain() on Watcom C for some reason.. */

BOOL APIENTRY
Expand All @@ -471,6 +469,4 @@ _DllMainCRTStartup(HANDLE hModule,
}
#endif /* building DLL with Watcom C */

#endif /* __WIN32__ */

/* vi: set sts=4 ts=4 sw=4 expandtab: */

0 comments on commit 3c9d333

Please sign in to comment.