Pagma pack warning with vs 2019 (16.1), cmake and clang

When using Visual Studio 2019 (16.1) with Cmake extensions and build a (x64-)clang-Debug or -Release configuration, i get massive warnings due to the #pragma pack inside begin_code.h.

Namely, the #pragma warning(disable: 4103) on line 106 does not appear to do its job (probably due to this being run though clang-cl).

Im currently manually supressing it in this specific configuration by setting -Wno-pragma-pack from cmake, but i suppose some people might run into this at some point, too.

I guess this probably is not a problem of SDL but of clang-cl missing compatibility with that specific #pragma, but maybe im just misinterpreting something.

I have honestly no idea where to look for a solution, so any suggestions are appreciated.


After testing around a bit, i found that _MSC_VER is defined on clang on windows, but clang never really understands the #pragma warning directives.
I opened a bug, this could be easily addressed, though i admit this is somewaht of an niche issue.


1 Like

#pragma warning is MSVC++ specific, as are the warning codes. For clang, you have to do

#pragma clang diagnostic push
#pragma clang diagnostic ignore "-Wno-pragma-pack"
// your code here
#pragma clang diagnostic pop

SDL authors probably figured that if you’re compiling a Windows game on Windows using Visual Studio then you’re also using MSVC++