| Summary: | fix for bug 2121 breaks linking for mingw and throws multiple warnings | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Andreas Ertelt <bugzilla-sdl> |
| Component: | *don't know* | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | CC: | parasti+libsdl |
| Version: | HG 2.0 | ||
| Hardware: | x86_64 | ||
| OS: | Windows 8 | ||
| Attachments: | Proposed fix | ||
|
Description
Andreas Ertelt
2013-10-02 05:29:04 UTC
Do you have a proposed fix? I don't have that environment set up, so I can't test this. Thanks! This would do the job: #if !SDL_INLINE_OKAY || __STRICT_ANSI__ && !__MINGW32__ Does mingw32 define __STRICT_ANSI__? Or does SDL_INLINE_OKAY not end up getting set for some reason? __STRICT_ANSI__ is implied when using any of the ansi/iso standards (eg. c90, c98, c++11, etc.). SDL_INLINE_OKAY is defined in line 119 for MINGW, which now gets overridden by __STRICT_ANSI__ and forces a redifinition of __inline__ which should not occur in MINGW environments. If the problem had been caused by an undefined SDL_INLINE_OKAY it would have existed prior to this patch ;) Just noticed this. I made the original bug report. (Wish you'd reopened that one instead of making a new one!) I can confirm that the fix breaks MinGW builds hardcore. Fundamentally, the problem is that SDL redefines the __inline__ keyword to mean nothing, and this definition is then leaked to system headers which have been written with the full expectation that __inline__ is not going to be nothing. It seems that __inline__ works even in ANSI C (at least when using GCC): http://gcc.gnu.org/onlinedocs/gcc/Inline.html Created attachment 1358 [details]
Proposed fix
I put together a quick patch. It doesn't throw errors or warnings on my MinGW cross-compile setup nor native Linux when compiling ANSI C code, but I can't really say if it still works, either. In the very least, I think not hijacking __inline__ would be a good first step.
Fixed, thanks! http://hg.libsdl.org/SDL/rev/2b0bcdea3a79 Reopening as compilation with ANSI C throws lots of unnecessary warnings, both using MinGW and using Linux GCC. (BTW, what happened? MinGW is broken to all hell. sdl2-config does not even link SDLMain anymore?) I think this may have been lost somewhere, so again: GCC supports inlining via __inline__ in all known versions of GCC, regardless of the C standard in use. Please don't assume that __STRICT_ANSI__ implies no inlining support. My patch addressed the original problem (that I reported) as well as the problems with the fix (reported by Andreas Ertelt). Was there a problem with it that made it unsuitable on a particular compiler? No, your patch was fine. I didn't realize that __inline__ was always available with gcc. Thanks! http://hg.libsdl.org/SDL/rev/ca36ab2a8179 Please report separate bugs with mingw builds. I just installed msys and the latest mingw32 gcc on Windows 7 a few days ago and successfully built and used SDL in that configuration. |