Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix name clash with std::byte #764

Merged
merged 2 commits into from
Sep 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions src/simulators/iCubSimulation/odesdl/MS3D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ bool Model::loadModelData( const char *filename )
if ( pHeader->m_version < 3 )
return false; // "Unhandled file version. Only Milkshape3D Version 1.3 and 1.4 is supported." );

int nVertices = *( word* )pPtr;
int nVertices = *( ms3d::word* )pPtr;
m_numVertices = nVertices;
m_pVertices = new Vertex[nVertices];
pPtr += sizeof( word );
pPtr += sizeof( ms3d::word );

int i;
for ( i = 0; i < nVertices; i++ )
Expand All @@ -130,10 +130,10 @@ bool Model::loadModelData( const char *filename )
pPtr += sizeof( MS3DVertex );
}

int nTriangles = *( word* )pPtr;
int nTriangles = *( ms3d::word* )pPtr;
m_numTriangles = nTriangles;
m_pTriangles = new Triangle[nTriangles];
pPtr += sizeof( word );
pPtr += sizeof( ms3d::word );

for ( i = 0; i < nTriangles; i++ )
{
Expand All @@ -149,22 +149,22 @@ bool Model::loadModelData( const char *filename )



int nGroups = *( word* )pPtr;
int nGroups = *( ms3d::word* )pPtr;
m_numMeshes = nGroups;
m_pMeshes = new Mesh[nGroups];
pPtr += sizeof( word );
pPtr += sizeof( ms3d::word );
for ( i = 0; i < nGroups; i++ )
{
pPtr += sizeof( byte ); // flags
pPtr += sizeof( ms3d::byte ); // flags
pPtr += 32; // name

word nTriangles = *( word* )pPtr;
pPtr += sizeof( word );
ms3d::word nTriangles = *( ms3d::word* )pPtr;
pPtr += sizeof( ms3d::word );
int *pTriangleIndices = new int[nTriangles];
for ( int j = 0; j < nTriangles; j++ )
{
pTriangleIndices[j] = *( word* )pPtr;
pPtr += sizeof( word );
pTriangleIndices[j] = *( ms3d::word* )pPtr;
pPtr += sizeof( ms3d::word );
}

char materialIndex = *( char* )pPtr;
Expand All @@ -175,10 +175,10 @@ bool Model::loadModelData( const char *filename )
m_pMeshes[i].m_pTriangleIndices = pTriangleIndices;
}

int nMaterials = *( word* )pPtr;
int nMaterials = *( ms3d::word* )pPtr;
m_numMaterials = nMaterials;
m_pMaterials = new Material[nMaterials];
pPtr += sizeof( word );
pPtr += sizeof( ms3d::word );
for ( i = 0; i < nMaterials; i++ )
{
MS3DMaterial *pMaterial = ( MS3DMaterial* )pPtr;
Expand Down
20 changes: 11 additions & 9 deletions src/simulators/iCubSimulation/odesdl/MS3D.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,10 @@
# error you must byte-align these structures with the appropriate compiler directives
#endif

typedef unsigned char byte;
typedef unsigned short word;
namespace ms3d {
typedef unsigned char byte;
typedef unsigned short word;
}

struct MS3DHeader // File Header
{
Expand All @@ -81,20 +83,20 @@ struct MS3DHeader // File Header

struct MS3DVertex // Vertex info
{
byte m_flags;
ms3d::byte m_flags;
float m_vertex[3];
char m_boneID;
byte m_refCount;
ms3d::byte m_refCount;
} PACK_STRUCT;

struct MS3DTriangle // Triangle info
{
word m_flags;
word m_vertexIndices[3];
ms3d::word m_flags;
ms3d::word m_vertexIndices[3];
float m_vertexNormals[3][3];
float m_s[3], m_t[3];
byte m_smoothingGroup;
byte m_groupIndex;
ms3d::byte m_smoothingGroup;
ms3d::byte m_groupIndex;
} PACK_STRUCT;

struct MS3DMaterial // Material info
Expand All @@ -108,7 +110,7 @@ struct MS3DMaterial // Material info
float m_emissive[4];
float m_shininess; // 0.0f - 128.0f
float m_transparency; // 0.0f - 1.0f
byte m_mode; // 0, 1, 2 (unused now)
ms3d::byte m_mode; // 0, 1, 2 (unused now)
char m_texture[128];
char m_alphamap[128];
} PACK_STRUCT;
Expand Down
3 changes: 3 additions & 0 deletions src/tools/skinManagerGui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ add_executable(skinManagerGui WIN32 ${skinManagerGui_SRCS}
${skinManagerGui_HDRS}
${skinManagerGui_QRC_GEN_SRCS}
${skinManagerGui_UI_GEN_SRCS})
if(WIN32)
target_compile_definitions(skinManagerGui PUBLIC _HAS_STD_BYTE=0)
endif()
Comment on lines +39 to +41
Copy link
Member Author

@pattacini pattacini Sep 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently, there's a native problem with some Windows SDK and std::byte defined in C++17.
This problem impacts the compilation of some skinManagerGui auto-generated files.

Here's the proposed solution.

We also need to be careful as in the future _HAS_STD_BYTE will get removed.

cc @Nicogene @traversaro @vtikha

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we open an issue on how to fix this in a more permanent way? Perhaps just avoiding a windows include or a using namespaces std somewhere in skinManagerGui could help in this case.

Copy link
Member

@traversaro traversaro Sep 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[rem]: https://github.com/microsoft/STL/issues/20

I guess there was a typo and the correct issues is microsoft/STL#204 ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we open an issue on how to fix this in a more permanent way? Perhaps just avoiding a windows include or a using namespaces std somewhere in skinManagerGui could help in this case.

Unfortunately, the failure is triggered within files that are generated by Qt, which in turn do include the "problematic" Windows SDK resources.

After a quick F2F alignment, we've decided to go this way.

target_link_libraries(skinManagerGui YARP::YARP_OS
YARP::YARP_init
YARP::YARP_sig
Expand Down