mosra / magnum

Lightweight and modular C++11 graphics middleware for games and data visualization
https://magnum.graphics/
Other
4.75k stars 439 forks source link

Get rid of "reinterpret_cast: conversion from T to void * of greater size" MSVC warnings #544

Closed pezcode closed 6 months ago

pezcode commented 2 years ago

This warning keeps showing up in our code, would be nice to have it fixed/silenced for a pristine warning list (at least as far as magnum is concerned 😄)

Warning C4312 'reinterpret_cast': conversion from 'T' to 'void *' of greater size

https://github.com/mosra/magnum/blob/663c9e17b7010414d6be7d95c894dc6ddad63e1f/src/Magnum/Trade/MeshData.h#L2163

mosra commented 2 years ago

Yeah I'm aware, and this is far from being the only place. I'm abusing void* to print stuff in hex, basically all enum debug output functions throw the same warning.

This will get all cleaned up once I have Debug::hex / oct / bin / chr / str modifiers implemented. It's bothering me for quite a while but didn't find enough free time to do that yet.

mosra commented 6 months ago

Debug::hex is implemented in mosra/corrade@718e5fd7e0c719d54eff722448400e7482274df7 and is used instead of reinterpret_cast in debug output operators since mosra/corrade@b160eda4106a459e911a5e7230f07d6da50b2ebb and 4435877cf1cf91445c149c55aa22c94b9170788e. Accompanying changes in other repos will follow.

I also took this as an opportunity to get rid of hopefully all remaining warnings on MSVC 2017+ in all repos and including tests, so in case you still come across some, don't hesitate to complain :)