We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 3832

Summary: [PATCH] Compilation error with "IMG_jpg.c" on Mac OS X
Product: SDL_image Reporter: Holger Schemel <sdl-bugzilla>
Component: miscAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2    
Version: 2.0.1   
Hardware: x86_64   
OS: Mac OS X 10.11   
Attachments: patch

Description Holger Schemel 2017-09-18 15:20:37 UTC
Created attachment 2948 [details]
patch

Summary: Error when compiling file "IMG_jpg.c" on Mac OS X.

This compilation error may possibly only occur in certain cases (maybe depending on what "./configure" detected); however, it will always occur if the first "#if" (at the very top of the file) results in the corresponding #if/#endif block to be skipped.

In this case, the remaining part of the source file (starting with "#define SAVE_JPG" / "#ifdef SAVE_JPG") will always be compiled, but has no SDL stuff defined (like "SDL_Surface" etc.), because "SDL_image.h" was never included in this case, and will therefore fail with a compiler error.

The attached patch simply moves that first "#if" below the "#include"s, which fixes the problem.
Comment 1 Sam Lantinga 2017-09-18 23:07:32 UTC
Fixed, thanks!
https://hg.libsdl.org/SDL_image/rev/90b2de23ea5e
Comment 2 Sam Lantinga 2017-09-18 23:07:49 UTC
This is now fixed.