discord / discord-rpc

https://discordapp.com/developers
MIT License
1.06k stars 327 forks source link

DiscordRichPresence: Warning C4820 #101

Closed gudenau closed 6 years ago

gudenau commented 6 years ago

When compiling a project with discord-rpc.h included and compiled with Visual Studio's compiler generates a warning about padding. The structure DiscordRichPresence has a warning about padding added after the member instance.

Warning: discord-rpc.h(42): warning C4820: 'DiscordRichPresence': '7' bytes padding added after data member 'instance'

Please note, I have manually applied #100 to the header file.

Rapptz commented 6 years ago

This is mainly a bogus warning. You can ignore it.

Of course there's going to be padding applied.

Use /W4 instead of /Wall when compiling maybe.

gudenau commented 6 years ago

I can't do that with this, that's not my change to make. How would I fix it in a cross platform way I could disable this specific warning for this specific structure?

Rapptz commented 6 years ago

https://msdn.microsoft.com/en-us/library/2c8f766e.aspx

gudenau commented 6 years ago

Is that valid on GCC?

Rapptz commented 6 years ago

No. That's an MSVC warning and pragmas are by definition compiler specific.

gudenau commented 6 years ago

So how do you fix this in a way where the same header works on VS and GCC?

crmarsh commented 6 years ago

Add 7 bytes of padding explicitly.

But seriously, this is not a problem. If the rest of your code base compiles cleanly with /Wall I'm extremely surprised.

gudenau commented 6 years ago

It does, all warnings are treated as errors and if there's a warning they get fixed to help guarantee defined and repeatable behavior across 32/64 bit Linux, Windows and Mac.

My personal projects also use Wall and treat warnings as errors.

crmarsh commented 6 years ago

You can't even include standard system headers with all warnings enabled. I can't imagine considering the lengths you go to to make this happen time well spent. Also, if you do this, you must be working around C4820 constantly, I don't know why you'd need to ask about it.

gudenau commented 6 years ago

Well, I did not make most of the code of this particular project and -Wall does not mess up GCC so I dunno.

Rapptz commented 6 years ago

-Wall for GCC is not equivalent to /Wall in MSVC. Compiler warnings are unsurprisingly compiler specific. The "sane" level of warnings for MSVC is /W4, not /Wall. This is more inline with -Wall for GCC.

The stdlib for MSVC doesn't even compile cleanly with /Wall nor is it a goal for their team because /Wall produces way too much noise, like the one you encountered.