From 0c76896458eabfff2bb52aedc0073325b76fd8e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Mon, 2 Mar 2020 21:55:10 +0100 Subject: [PATCH] Trade: various MSVC workarounds. --- src/Magnum/Trade/Test/MeshDataTest.cpp | 30 +++++++++++++++----------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/Magnum/Trade/Test/MeshDataTest.cpp b/src/Magnum/Trade/Test/MeshDataTest.cpp index a72aaee30..70448ce10 100644 --- a/src/Magnum/Trade/Test/MeshDataTest.cpp +++ b/src/Magnum/Trade/Test/MeshDataTest.cpp @@ -675,7 +675,12 @@ void MeshDataTest::constructAttributeWrongDataAccess() { "Trade::MeshAttributeData::data(): the attribute is a relative offset, supply a data array\n"); } -constexpr Vector2 ArrayVertexData[3*4]; +constexpr Vector2 ArrayVertexData[3*4] + /* MSVC 2015 needs an explicit initializer. GCC 4.8 *doesn't*. */ + #ifdef CORRADE_MSVC2015_COMPATIBILITY + {} + #endif + ; void MeshDataTest::constructArrayAttribute() { Vector2 vertexData[3*4]; @@ -2063,18 +2068,22 @@ void MeshDataTest::colorsIntoArrayInvalidSize() { "Trade::MeshData::colorsInto(): expected a view with 3 elements but got 2\n"); } +/* MSVC 2015 doesn't like anonymous bitfields in inline structs, so putting the + declaration outside */ +struct VertexWithImplementationSpecificData { + Long:64; + long double thing; +}; + void MeshDataTest::implementationSpecificVertexFormat() { - struct Vertex { - Long:64; - long double thing; - } vertexData[] { + VertexWithImplementationSpecificData vertexData[] { {456.0l}, {456.0l} }; /* Constructing should work w/o asserts */ Containers::StridedArrayView1D attribute{vertexData, - &vertexData[0].thing, 2, sizeof(Vertex)}; + &vertexData[0].thing, 2, sizeof(VertexWithImplementationSpecificData)}; MeshData data{MeshPrimitive::TriangleFan, DataFlag::Mutable, vertexData, { MeshAttributeData{MeshAttribute::Position, vertexFormatWrap(0xdead1), attribute}, @@ -2095,7 +2104,7 @@ void MeshDataTest::implementationSpecificVertexFormat() { CORRADE_COMPARE(data.attributeFormat(name), vertexFormatWrap(format++)); /* The actual type size is unknown, so this will use the full stride */ - CORRADE_COMPARE(data.attribute(name).size()[1], sizeof(Vertex)); + CORRADE_COMPARE(data.attribute(name).size()[1], sizeof(VertexWithImplementationSpecificData)); CORRADE_COMPARE_AS((Containers::arrayCast<1, const long double>( data.attribute(name).prefix({2, sizeof(long double)}))), @@ -2107,16 +2116,13 @@ void MeshDataTest::implementationSpecificVertexFormat() { } void MeshDataTest::implementationSpecificVertexFormatWrongAccess() { - struct Vertex { - Long:64; - long double thing; - } vertexData[] { + VertexWithImplementationSpecificData vertexData[] { {456.0l}, {456.0l} }; Containers::StridedArrayView1D attribute{vertexData, - &vertexData[0].thing, 2, sizeof(Vertex)}; + &vertexData[0].thing, 2, sizeof(VertexWithImplementationSpecificData)}; MeshData data{MeshPrimitive::TriangleFan, DataFlag::Mutable, vertexData, { MeshAttributeData{MeshAttribute::Position, vertexFormatWrap(0xdead1), attribute},