Skip to content

Commit

Permalink
Use the new Debug::hex instead of reinterpret_cast<void*>().
Browse files Browse the repository at this point in the history
This finally fixes most of those annoying MSVC C4312 warnings about
conversion to a type of a greater size.
  • Loading branch information
mosra committed Mar 5, 2024
1 parent 81855a1 commit 4435877
Show file tree
Hide file tree
Showing 83 changed files with 208 additions and 205 deletions.
3 changes: 3 additions & 0 deletions doc/changelog.dox
Expand Up @@ -1051,6 +1051,9 @@ See also:
libraries, as that breaks builds with version 3.1.52+. See
[mosra/magnum#633](https://github.com/mosra/magnum/issues/633) for more
information.
- Fixed most remaining warnings on MSVC, in particular those related to
"conversion from T to void * of greater size" (see
[mosra/magnum#544](https://github.com/mosra/magnum/issues/544)).

@subsection changelog-latest-bugfixes Bug fixes

Expand Down
4 changes: 2 additions & 2 deletions src/Magnum/Animation/Interpolation.cpp
Expand Up @@ -48,7 +48,7 @@ Debug& operator<<(Debug& debug, const Interpolation value) {
/* LCOV_EXCL_STOP */
}

return debug << (packed ? "" : "(") << Debug::nospace << reinterpret_cast<void*>(UnsignedByte(value)) << Debug::nospace << (packed ? "" : ")");
return debug << (packed ? "" : "(") << Debug::nospace << Debug::hex << UnsignedByte(value) << Debug::nospace << (packed ? "" : ")");
}

Debug& operator<<(Debug& debug, const Extrapolation value) {
Expand All @@ -67,7 +67,7 @@ Debug& operator<<(Debug& debug, const Extrapolation value) {
/* LCOV_EXCL_STOP */
}

return debug << (packed ? "" : "(") << Debug::nospace << reinterpret_cast<void*>(UnsignedByte(value)) << Debug::nospace << (packed ? "" : ")");
return debug << (packed ? "" : "(") << Debug::nospace << Debug::hex << UnsignedByte(value) << Debug::nospace << (packed ? "" : ")");
}
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/Magnum/Animation/Player.cpp
Expand Up @@ -40,7 +40,7 @@ Debug& operator<<(Debug& debug, const State value) {
/* LCOV_EXCL_STOP */
}

return debug << "(" << Debug::nospace << reinterpret_cast<void*>(UnsignedByte(value)) << Debug::nospace << ")";
return debug << "(" << Debug::nospace << Debug::hex << UnsignedByte(value) << Debug::nospace << ")";
}

/* On non-MinGW Windows the instantiations are already marked with extern
Expand Down
2 changes: 1 addition & 1 deletion src/Magnum/Audio/AbstractImporter.cpp
Expand Up @@ -154,7 +154,7 @@ Debug& operator<<(Debug& debug, const ImporterFeature value) {
/* LCOV_EXCL_STOP */
}

return debug << (packed ? "" : "(") << Debug::nospace << reinterpret_cast<void*>(UnsignedByte(value)) << Debug::nospace << (packed ? "" : ")");
return debug << (packed ? "" : "(") << Debug::nospace << Debug::hex << UnsignedByte(value) << Debug::nospace << (packed ? "" : ")");
}

Debug& operator<<(Debug& debug, const ImporterFeatures value) {
Expand Down
2 changes: 1 addition & 1 deletion src/Magnum/Audio/BufferFormat.cpp
Expand Up @@ -75,7 +75,7 @@ Debug& operator<<(Debug& debug, const BufferFormat value) {
/* LCOV_EXCL_STOP */
}

return debug << "(" << Debug::nospace << reinterpret_cast<void*>(ALenum(value)) << Debug::nospace << ")";
return debug << "(" << Debug::nospace << Debug::hex << ALenum(value) << Debug::nospace << ")";
}

}}
2 changes: 1 addition & 1 deletion src/Magnum/Audio/Context.cpp
Expand Up @@ -84,7 +84,7 @@ Debug& operator<<(Debug& debug, const Context::HrtfStatus value) {
/* LCOV_EXCL_STOP */
}

return debug << "(" << Debug::nospace << reinterpret_cast<void*>(ALenum(value)) << Debug::nospace << ")";
return debug << "(" << Debug::nospace << Debug::hex << ALenum(value) << Debug::nospace << ")";
}

namespace {
Expand Down
4 changes: 2 additions & 2 deletions src/Magnum/Audio/Renderer.cpp
Expand Up @@ -45,7 +45,7 @@ Debug& operator<<(Debug& debug, const Renderer::Error value) {
/* LCOV_EXCL_STOP */
}

return debug << "(" << Debug::nospace << reinterpret_cast<void*>(ALenum(value)) << Debug::nospace << ")";
return debug << "(" << Debug::nospace << Debug::hex << ALenum(value) << Debug::nospace << ")";
}

Debug& operator<<(Debug& debug, const Renderer::DistanceModel value) {
Expand All @@ -65,7 +65,7 @@ Debug& operator<<(Debug& debug, const Renderer::DistanceModel value) {
/* LCOV_EXCL_STOP */
}

return debug << "(" << Debug::nospace << reinterpret_cast<void*>(ALenum(value)) << Debug::nospace << ")";
return debug << "(" << Debug::nospace << Debug::hex << ALenum(value) << Debug::nospace << ")";
}

}}
4 changes: 2 additions & 2 deletions src/Magnum/Audio/Source.cpp
Expand Up @@ -139,7 +139,7 @@ Debug& operator<<(Debug& debug, const Source::State value) {
/* LCOV_EXCL_STOP */
}

return debug << "(" << Debug::nospace << reinterpret_cast<void*>(ALint(value)) << Debug::nospace << ")";
return debug << "(" << Debug::nospace << Debug::hex << ALint(value) << Debug::nospace << ")";
}

Debug& operator<<(Debug& debug, const Source::Type value) {
Expand All @@ -155,7 +155,7 @@ Debug& operator<<(Debug& debug, const Source::Type value) {
/* LCOV_EXCL_STOP */
}

return debug << "(" << Debug::nospace << reinterpret_cast<void*>(ALint(value)) << Debug::nospace << ")";
return debug << "(" << Debug::nospace << Debug::hex << ALint(value) << Debug::nospace << ")";
}

}}
4 changes: 2 additions & 2 deletions src/Magnum/DebugTools/FrameProfiler.cpp
Expand Up @@ -427,7 +427,7 @@ Debug& operator<<(Debug& debug, const FrameProfiler::Units value) {
/* LCOV_EXCL_STOP */
}

return debug << "(" << Debug::nospace << reinterpret_cast<void*>(UnsignedByte(value)) << Debug::nospace << ")";
return debug << "(" << Debug::nospace << Debug::hex << UnsignedByte(value) << Debug::nospace << ")";
}

#ifdef MAGNUM_TARGET_GL
Expand Down Expand Up @@ -656,7 +656,7 @@ Debug& operator<<(Debug& debug, const FrameProfilerGL::Value value) {
if(1 << bit == UnsignedShort(value))
return debug << "::" << Debug::nospace << FrameProfilerGLValueNames[bit];

return debug << "(" << Debug::nospace << reinterpret_cast<void*>(UnsignedShort(value)) << Debug::nospace << ")";
return debug << "(" << Debug::nospace << Debug::hex << UnsignedShort(value) << Debug::nospace << ")";
}

Debug& operator<<(Debug& debug, const FrameProfilerGL::Values value) {
Expand Down
2 changes: 1 addition & 1 deletion src/Magnum/FileCallback.cpp
Expand Up @@ -42,7 +42,7 @@ Debug& operator<<(Debug& debug, const InputFileCallbackPolicy value) {
/* LCOV_EXCL_STOP */
}

return debug << "(" << Debug::nospace << reinterpret_cast<void*>(UnsignedByte(value)) << Debug::nospace << ")";
return debug << "(" << Debug::nospace << Debug::hex << UnsignedByte(value) << Debug::nospace << ")";
}

}
32 changes: 16 additions & 16 deletions src/Magnum/GL/Attribute.cpp
Expand Up @@ -50,7 +50,7 @@ Debug& operator<<(Debug& debug, const DynamicAttribute::Kind value) {
/* LCOV_EXCL_STOP */
}

return debug << "(" << Debug::nospace << reinterpret_cast<void*>(GLenum(value)) << Debug::nospace << ")";
return debug << "(" << Debug::nospace << Debug::hex << GLenum(value) << Debug::nospace << ")";
}

Debug& operator<<(Debug& debug, const DynamicAttribute::Components value) {
Expand All @@ -70,7 +70,7 @@ Debug& operator<<(Debug& debug, const DynamicAttribute::Components value) {
/* LCOV_EXCL_STOP */
}

return debug << "(" << Debug::nospace << reinterpret_cast<void*>(GLint(value)) << Debug::nospace << ")";
return debug << "(" << Debug::nospace << Debug::hex << GLint(value) << Debug::nospace << ")";
}

Debug& operator<<(Debug& debug, const DynamicAttribute::DataType value) {
Expand Down Expand Up @@ -101,7 +101,7 @@ Debug& operator<<(Debug& debug, const DynamicAttribute::DataType value) {
/* LCOV_EXCL_STOP */
}

return debug << "(" << Debug::nospace << reinterpret_cast<void*>(GLenum(value)) << Debug::nospace << ")";
return debug << "(" << Debug::nospace << Debug::hex << GLenum(value) << Debug::nospace << ")";
}

namespace Implementation {
Expand Down Expand Up @@ -231,7 +231,7 @@ Debug& operator<<(Debug& debug, const SizedAttribute<1, 1>::Components value) {
/* LCOV_EXCL_STOP */
}

return debug << "(" << Debug::nospace << reinterpret_cast<void*>(GLint(value)) << Debug::nospace << ")";
return debug << "(" << Debug::nospace << Debug::hex << GLint(value) << Debug::nospace << ")";
}

Debug& operator<<(Debug& debug, const SizedAttribute<1, 2>::Components value) {
Expand All @@ -246,7 +246,7 @@ Debug& operator<<(Debug& debug, const SizedAttribute<1, 2>::Components value) {
/* LCOV_EXCL_STOP */
}

return debug << "(" << Debug::nospace << reinterpret_cast<void*>(GLint(value)) << Debug::nospace << ")";
return debug << "(" << Debug::nospace << Debug::hex << GLint(value) << Debug::nospace << ")";
}

Debug& operator<<(Debug& debug, const SizedAttribute<1, 3>::Components value) {
Expand All @@ -263,7 +263,7 @@ Debug& operator<<(Debug& debug, const SizedAttribute<1, 3>::Components value) {
/* LCOV_EXCL_STOP */
}

return debug << "(" << Debug::nospace << reinterpret_cast<void*>(GLint(value)) << Debug::nospace << ")";
return debug << "(" << Debug::nospace << Debug::hex << GLint(value) << Debug::nospace << ")";
}

Debug& operator<<(Debug& debug, const SizedAttribute<1, 4>::Components value) {
Expand All @@ -282,7 +282,7 @@ Debug& operator<<(Debug& debug, const SizedAttribute<1, 4>::Components value) {
/* LCOV_EXCL_STOP */
}

return debug << "(" << Debug::nospace << reinterpret_cast<void*>(GLint(value)) << Debug::nospace << ")";
return debug << "(" << Debug::nospace << Debug::hex << GLint(value) << Debug::nospace << ")";
}

Debug& operator<<(Debug& debug, const SizedMatrixAttribute<2>::Components value) {
Expand All @@ -295,7 +295,7 @@ Debug& operator<<(Debug& debug, const SizedMatrixAttribute<2>::Components value)
/* LCOV_EXCL_STOP */
}

return debug << "(" << Debug::nospace << reinterpret_cast<void*>(GLint(value)) << Debug::nospace << ")";
return debug << "(" << Debug::nospace << Debug::hex << GLint(value) << Debug::nospace << ")";
}

Debug& operator<<(Debug& debug, const SizedMatrixAttribute<3>::Components value) {
Expand All @@ -308,7 +308,7 @@ Debug& operator<<(Debug& debug, const SizedMatrixAttribute<3>::Components value)
/* LCOV_EXCL_STOP */
}

return debug << "(" << Debug::nospace << reinterpret_cast<void*>(GLint(value)) << Debug::nospace << ")";
return debug << "(" << Debug::nospace << Debug::hex << GLint(value) << Debug::nospace << ")";
}

Debug& operator<<(Debug& debug, const SizedMatrixAttribute<4>::Components value) {
Expand All @@ -321,7 +321,7 @@ Debug& operator<<(Debug& debug, const SizedMatrixAttribute<4>::Components value)
/* LCOV_EXCL_STOP */
}

return debug << "(" << Debug::nospace << reinterpret_cast<void*>(GLint(value)) << Debug::nospace << ")";
return debug << "(" << Debug::nospace << Debug::hex << GLint(value) << Debug::nospace << ")";
}

Debug& operator<<(Debug& debug, const Attribute<Math::Vector<4, Float>>::Components value) {
Expand All @@ -344,7 +344,7 @@ Debug& operator<<(Debug& debug, const Attribute<Math::Vector<4, Float>>::Compone
/* LCOV_EXCL_STOP */
}

return debug << "(" << Debug::nospace << reinterpret_cast<void*>(GLint(value)) << Debug::nospace << ")";
return debug << "(" << Debug::nospace << Debug::hex << GLint(value) << Debug::nospace << ")";
}

Debug& operator<<(Debug& debug, const FloatAttribute::DataType value) {
Expand All @@ -370,7 +370,7 @@ Debug& operator<<(Debug& debug, const FloatAttribute::DataType value) {
/* LCOV_EXCL_STOP */
}

return debug << "(" << Debug::nospace << reinterpret_cast<void*>(GLenum(value)) << Debug::nospace << ")";
return debug << "(" << Debug::nospace << Debug::hex << GLenum(value) << Debug::nospace << ")";
}

#ifndef MAGNUM_TARGET_GLES2
Expand All @@ -390,7 +390,7 @@ Debug& operator<<(Debug& debug, const IntAttribute::DataType value) {
/* LCOV_EXCL_STOP */
}

return debug << "(" << Debug::nospace << reinterpret_cast<void*>(GLenum(value)) << Debug::nospace << ")";
return debug << "(" << Debug::nospace << Debug::hex << GLenum(value) << Debug::nospace << ")";
}
#endif

Expand All @@ -406,7 +406,7 @@ Debug& operator<<(Debug& debug, const DoubleAttribute::DataType value) {
/* LCOV_EXCL_STOP */
}

return debug << "(" << Debug::nospace << reinterpret_cast<void*>(GLenum(value)) << Debug::nospace << ")";
return debug << "(" << Debug::nospace << Debug::hex << GLenum(value) << Debug::nospace << ")";
}
#endif

Expand Down Expand Up @@ -434,7 +434,7 @@ Debug& operator<<(Debug& debug, const Attribute<Math::Vector<3, Float>>::DataTyp
/* LCOV_EXCL_STOP */
}

return debug << "(" << Debug::nospace << reinterpret_cast<void*>(GLenum(value)) << Debug::nospace << ")";
return debug << "(" << Debug::nospace << Debug::hex << GLenum(value) << Debug::nospace << ")";
}

Debug& operator<<(Debug& debug, const Attribute<Math::Vector<4, Float>>::DataType value) {
Expand Down Expand Up @@ -464,7 +464,7 @@ Debug& operator<<(Debug& debug, const Attribute<Math::Vector<4, Float>>::DataTyp
/* LCOV_EXCL_STOP */
}

return debug << "(" << Debug::nospace << reinterpret_cast<void*>(GLenum(value)) << Debug::nospace << ")";
return debug << "(" << Debug::nospace << Debug::hex << GLenum(value) << Debug::nospace << ")";
}

}
Expand Down
4 changes: 2 additions & 2 deletions src/Magnum/GL/Buffer.cpp
Expand Up @@ -716,7 +716,7 @@ Debug& operator<<(Debug& debug, const Buffer::TargetHint value) {
/* LCOV_EXCL_STOP */
}

return debug << "(" << Debug::nospace << reinterpret_cast<void*>(GLenum(value)) << Debug::nospace << ")";
return debug << "(" << Debug::nospace << Debug::hex << GLenum(value) << Debug::nospace << ")";
}

#ifndef MAGNUM_TARGET_GLES2
Expand All @@ -733,7 +733,7 @@ Debug& operator<<(Debug& debug, const Buffer::Target value) {
#undef _c
}

return debug << "(" << Debug::nospace << reinterpret_cast<void*>(GLenum(value)) << Debug::nospace << ")";
return debug << "(" << Debug::nospace << Debug::hex << GLenum(value) << Debug::nospace << ")";
}
#endif
#endif
Expand Down
4 changes: 2 additions & 2 deletions src/Magnum/GL/Context.cpp
Expand Up @@ -1341,7 +1341,7 @@ Debug& operator<<(Debug& debug, const Context::Flag value) {
/* LCOV_EXCL_STOP */
}

return debug << (packed ? "" : "(") << Debug::nospace << reinterpret_cast<void*>(GLint(value)) << Debug::nospace << (packed ? "" : ")");
return debug << (packed ? "" : "(") << Debug::nospace << Debug::hex << GLint(value) << Debug::nospace << (packed ? "" : ")");
}

Debug& operator<<(Debug& debug, const Context::Flags value) {
Expand Down Expand Up @@ -1388,7 +1388,7 @@ Debug& operator<<(Debug& debug, const Context::DetectedDriver value) {
/* LCOV_EXCL_STOP */
}

return debug << (packed ? "" : "(") << Debug::nospace << reinterpret_cast<void*>(GLint(value)) << Debug::nospace << (packed ? "" : ")");
return debug << (packed ? "" : "(") << Debug::nospace << Debug::hex << GLint(value) << Debug::nospace << (packed ? "" : ")");
}

Debug& operator<<(Debug& debug, const Context::DetectedDrivers value) {
Expand Down
12 changes: 6 additions & 6 deletions src/Magnum/GL/DebugOutput.cpp
Expand Up @@ -248,7 +248,7 @@ Debug& operator<<(Debug& debug, const DebugOutput::Source value) {
/* LCOV_EXCL_STOP */
}

return debug << "(" << Debug::nospace << reinterpret_cast<void*>(GLenum(value)) << Debug::nospace << ")";
return debug << "(" << Debug::nospace << Debug::hex << GLenum(value) << Debug::nospace << ")";
}

Debug& operator<<(Debug& debug, const DebugOutput::Type value) {
Expand All @@ -270,7 +270,7 @@ Debug& operator<<(Debug& debug, const DebugOutput::Type value) {
/* LCOV_EXCL_STOP */
}

return debug << "(" << Debug::nospace << reinterpret_cast<void*>(GLenum(value)) << Debug::nospace << ")";
return debug << "(" << Debug::nospace << Debug::hex << GLenum(value) << Debug::nospace << ")";
}

Debug& operator<<(Debug& debug, const DebugOutput::Severity value) {
Expand All @@ -285,7 +285,7 @@ Debug& operator<<(Debug& debug, const DebugOutput::Severity value) {
#undef _c
}

return debug << "(" << Debug::nospace << reinterpret_cast<void*>(GLenum(value)) << Debug::nospace << ")";
return debug << "(" << Debug::nospace << Debug::hex << GLenum(value) << Debug::nospace << ")";
}
#endif

Expand Down Expand Up @@ -330,7 +330,7 @@ Debug& operator<<(Debug& debug, const DebugMessage::Source value) {
/* LCOV_EXCL_STOP */
}

return debug << "(" << Debug::nospace << reinterpret_cast<void*>(GLenum(value)) << Debug::nospace << ")";
return debug << "(" << Debug::nospace << Debug::hex << GLenum(value) << Debug::nospace << ")";
}

Debug& operator<<(Debug& debug, const DebugMessage::Type value) {
Expand All @@ -348,7 +348,7 @@ Debug& operator<<(Debug& debug, const DebugMessage::Type value) {
#undef _c
}

return debug << "(" << Debug::nospace << reinterpret_cast<void*>(GLenum(value)) << Debug::nospace << ")";
return debug << "(" << Debug::nospace << Debug::hex << GLenum(value) << Debug::nospace << ")";
}
#endif

Expand Down Expand Up @@ -434,7 +434,7 @@ Debug& operator<<(Debug& debug, const DebugGroup::Source value) {
/* LCOV_EXCL_STOP */
}

return debug << "(" << Debug::nospace << reinterpret_cast<void*>(GLenum(value)) << Debug::nospace << ")";
return debug << "(" << Debug::nospace << Debug::hex << GLenum(value) << Debug::nospace << ")";
}
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/Magnum/GL/DefaultFramebuffer.cpp
Expand Up @@ -140,7 +140,7 @@ Debug& operator<<(Debug& debug, const DefaultFramebuffer::Status value) {
/* LCOV_EXCL_STOP */
}

return debug << "(" << Debug::nospace << reinterpret_cast<void*>(GLenum(value)) << Debug::nospace << ")";
return debug << "(" << Debug::nospace << Debug::hex << GLenum(value) << Debug::nospace << ")";
}
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/Magnum/GL/Framebuffer.cpp
Expand Up @@ -482,7 +482,7 @@ Debug& operator<<(Debug& debug, const Framebuffer::Status value) {
/* LCOV_EXCL_STOP */
}

return debug << "(" << Debug::nospace << reinterpret_cast<void*>(GLenum(value)) << Debug::nospace << ")";
return debug << "(" << Debug::nospace << Debug::hex << GLenum(value) << Debug::nospace << ")";
}
#endif

Expand Down
4 changes: 2 additions & 2 deletions src/Magnum/GL/Mesh.cpp
Expand Up @@ -144,7 +144,7 @@ Debug& operator<<(Debug& debug, const MeshPrimitive value) {
/* LCOV_EXCL_STOP */
}

return debug << "(" << Debug::nospace << reinterpret_cast<void*>(GLenum(value)) << Debug::nospace << ")";
return debug << "(" << Debug::nospace << Debug::hex << GLenum(value) << Debug::nospace << ")";
}

Debug& operator<<(Debug& debug, const MeshIndexType value) {
Expand All @@ -160,7 +160,7 @@ Debug& operator<<(Debug& debug, const MeshIndexType value) {
/* LCOV_EXCL_STOP */
}

return debug << "(" << Debug::nospace << reinterpret_cast<void*>(GLenum(value)) << Debug::nospace << ")";
return debug << "(" << Debug::nospace << Debug::hex << GLenum(value) << Debug::nospace << ")";
}
#endif

Expand Down

0 comments on commit 4435877

Please sign in to comment.