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 4641

Summary: clang and clang-cl builds on windows create -Wpragma-pack warnings
Product: SDL Reporter: Malte Kießling <mkalte>
Component: *don't know*Assignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2    
Version: HG 2.0   
Hardware: x86_64   
OS: Windows 10   
Attachments: Possible patch for begin_code.h
test.c
test.h
testFix.c
patch

Description Malte Kießling 2019-05-24 18:50:31 UTC
Created attachment 3792 [details]
Possible patch for begin_code.h

When compiling on windows with clang and clang-cl 

    #pragma warning(disable: 4103)

does nothing in begin_code.h, line 106. 

This can be replicated with a minimal example (test.cpp, test.h). I also will include the minimal fix i found (testFix.cpp) and a possible diff for begin_code.h

The Command outputs showing the warnings i added as a comment to the .c files.

~mkalte
Comment 1 Malte Kießling 2019-05-24 18:51:15 UTC
Created attachment 3793 [details]
test.c
Comment 2 Malte Kießling 2019-05-24 18:51:43 UTC
Created attachment 3794 [details]
test.h
Comment 3 Malte Kießling 2019-05-24 18:52:00 UTC
Created attachment 3795 [details]
testFix.c
Comment 4 Malte Kießling 2019-05-25 09:47:41 UTC
Thinking about it, considering that this is only clang, it might be better to use

#pragma clang diagnostic ignored "-Wpragma-pack"

instead of the GCC one, as was shown on the mailing list. 
However i cannot get the diagnostic push/pop to work without the warning, probably because the warning is generated after the include.
Comment 5 Sam Lantinga 2019-06-08 20:09:36 UTC
Can you show the output you see when using SDL headers? I'm fine with your fix, if it takes care of the problem in real-world use cases.
Comment 6 Malte Kießling 2019-06-09 08:49:09 UTC
Here is a minimal example current clang (8.0) using a buildbot build.

https://pastebin.com/UEqEQHgr
Comment 7 Sam Lantinga 2019-06-09 21:10:59 UTC
So if you add "#pragma clang diagnostic ignored "-Wpragma-pack"" to begin_code.h, does that fix the problem?
Comment 8 Malte Kießling 2019-06-09 23:10:52 UTC
Created attachment 3813 [details]
patch

Yep. I put it inside a "#ifdef __clang__" block to avoid conflicts and it goes all quiet. 

https://pastebin.com/czccH10j
Comment 9 Sam Lantinga 2019-06-10 15:46:39 UTC
Patch added, thanks!
https://hg.libsdl.org/SDL/rev/dbc1fc3b74b1