Skip to content

Commit 94b2e4a

Browse files
authored
Fix warnings (#201)
- internal use of deprecated type was not showing up with clang... - mark parameters as UNUSED - throw exception if switch not satisfied in WriterImpl - add type to std::uniform_real_distribution - use pragma to disable warning on Windows (since it doesn’t implement the standard for some reason)
1 parent c9cb82b commit 94b2e4a

9 files changed

+78
-16
lines changed

include/E57SimpleData.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -742,11 +742,11 @@ namespace e57
742742
using Data3DPointsData_d [[deprecated( "Will be removed in 4.0. Use Data3DPointsDouble." )]] =
743743
Data3DPointsData_t<double>;
744744

745-
extern template Data3DPointsFloat::Data3DPointsData_t( Data3D &data3D );
746-
extern template Data3DPointsDouble::Data3DPointsData_t( Data3D &data3D );
745+
extern template Data3DPointsData_t<float>::Data3DPointsData_t( Data3D &data3D );
746+
extern template Data3DPointsData_t<double>::Data3DPointsData_t( Data3D &data3D );
747747

748-
extern template Data3DPointsFloat::~Data3DPointsData_t();
749-
extern template Data3DPointsDouble::~Data3DPointsData_t();
748+
extern template Data3DPointsData_t<float>::~Data3DPointsData_t();
749+
extern template Data3DPointsData_t<double>::~Data3DPointsData_t();
750750

751751
/// @brief Stores an image that is to be used only as a visual reference.
752752
struct E57_DLL VisualReferenceRepresentation

include/E57SimpleWriter.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -163,13 +163,13 @@ namespace e57
163163
[[deprecated( "Will be removed in 4.0. Use WriteData3DData()." )]] // TODO Remove in 4.0
164164
CompressedVectorWriter
165165
SetUpData3DPointsData( int64_t dataIndex, size_t pointCount,
166-
const Data3DPointsData &buffers );
166+
const Data3DPointsFloat &buffers );
167167

168168
/// @overload
169169
[[deprecated( "Will be removed in 4.0. Use WriteData3DData()." )]] // TODO Remove in 4.0
170170
CompressedVectorWriter
171171
SetUpData3DPointsData( int64_t dataIndex, size_t pointCount,
172-
const Data3DPointsData_d &buffers );
172+
const Data3DPointsDouble &buffers );
173173

174174
/// @brief Writes out the group data
175175
/// @param [in] dataIndex data block index given by the NewData3D

src/CheckedFile.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -235,10 +235,16 @@ int CheckedFile::open64( const ustring &fileName, int flags, int mode )
235235
errno_t err = _wsopen_s( &handle, widePath.c_str(), flags, _SH_DENYNO, mode );
236236
if ( err != 0 )
237237
{
238+
// MSVC doesn't implement strerrorlen_s for some unknown reason, so just disable the warning
239+
#pragma warning( push )
240+
#pragma warning( disable : 4996 )
241+
238242
throw E57_EXCEPTION2( ErrorOpenFailed, "errno=" + toString( errno ) + " error='" +
239243
strerror( errno ) + "' fileName=" + fileName +
240244
" flags=" + toString( flags ) +
241245
" mode=" + toString( mode ) );
246+
247+
#pragma warning( pop )
242248
}
243249
return handle;
244250
#elif defined( __GNUC__ )

src/CompressedVectorReaderImpl.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,9 @@ namespace e57
577577
const char *srcFunctionName ) const
578578
{
579579
// unimplemented...
580+
UNUSED( srcFileName );
581+
UNUSED( srcLineNumber );
582+
UNUSED( srcFunctionName );
580583
}
581584

582585
void CompressedVectorReaderImpl::checkReaderOpen( const char *srcFileName, int srcLineNumber,

src/CompressedVectorWriterImpl.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,9 @@ namespace e57
621621
const char *srcFunctionName ) const
622622
{
623623
// unimplemented...
624+
UNUSED( srcFileName );
625+
UNUSED( srcLineNumber );
626+
UNUSED( srcFunctionName );
624627
}
625628

626629
void CompressedVectorWriterImpl::checkWriterOpen( const char *srcFileName, int srcLineNumber,

src/E57SimpleData.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,9 @@ namespace e57
247247
*this = Data3DPointsData_t<COORDTYPE>();
248248
}
249249

250-
template Data3DPointsFloat::Data3DPointsData_t( Data3D &data3D );
251-
template Data3DPointsDouble::Data3DPointsData_t( Data3D &data3D );
250+
template Data3DPointsData_t<float>::Data3DPointsData_t( Data3D &data3D );
251+
template Data3DPointsData_t<double>::Data3DPointsData_t( Data3D &data3D );
252252

253-
template Data3DPointsFloat::~Data3DPointsData_t();
254-
template Data3DPointsDouble::~Data3DPointsData_t();
253+
template Data3DPointsData_t<float>::~Data3DPointsData_t();
254+
template Data3DPointsData_t<double>::~Data3DPointsData_t();
255255
} // end namespace e57

src/E57SimpleWriter.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,9 @@ namespace
159159
}
160160
}
161161
template void _fillMinMaxData( e57::Data3D &ioData3DHeader,
162-
const e57::Data3DPointsData &inBuffers );
162+
const e57::Data3DPointsFloat &inBuffers );
163163
template void _fillMinMaxData( e57::Data3D &ioData3DHeader,
164-
const e57::Data3DPointsData_d &inBuffers );
164+
const e57::Data3DPointsDouble &inBuffers );
165165
}
166166

167167
namespace e57
@@ -256,13 +256,13 @@ namespace e57
256256
};
257257

258258
CompressedVectorWriter Writer::SetUpData3DPointsData( int64_t dataIndex, size_t pointCount,
259-
const Data3DPointsData &buffers )
259+
const Data3DPointsFloat &buffers )
260260
{
261261
return impl_->SetUpData3DPointsData( dataIndex, pointCount, buffers );
262262
}
263263

264264
CompressedVectorWriter Writer::SetUpData3DPointsData( int64_t dataIndex, size_t pointCount,
265-
const Data3DPointsData_d &buffers )
265+
const Data3DPointsDouble &buffers )
266266
{
267267
return impl_->SetUpData3DPointsData( dataIndex, pointCount, buffers );
268268
}

src/WriterImpl.cpp

+50
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,46 @@
3333
#include "Common.h"
3434
#include "E57Version.h"
3535

36+
namespace
37+
{
38+
/*!
39+
@brief Convert e57::NumericalNodeType into human-readable string.
40+
41+
@param inNodeType node type to convert
42+
43+
@return human-readable representation of node type or "Unknown: <node type int>".
44+
*/
45+
std::string _numericalNodeTypeStr( e57::NumericalNodeType inNodeType )
46+
{
47+
switch ( inNodeType )
48+
{
49+
case e57::NumericalNodeType::Integer:
50+
{
51+
return "Integer";
52+
}
53+
54+
case e57::NumericalNodeType::ScaledInteger:
55+
{
56+
return "ScaledInteger";
57+
}
58+
59+
case e57::NumericalNodeType::Float:
60+
{
61+
return "Float";
62+
}
63+
64+
case e57::NumericalNodeType::Double:
65+
{
66+
return "Double";
67+
}
68+
69+
default:
70+
return std::string( "Unknown: " )
71+
.append( std::to_string( static_cast<int>( inNodeType ) ) );
72+
}
73+
}
74+
}
75+
3676
namespace e57
3777
{
3878
/*!
@@ -829,6 +869,11 @@ namespace e57
829869
return FloatNode( imf_, 0.0, PrecisionDouble, pointRangeMin, pointRangeMax );
830870
}
831871
}
872+
873+
throw E57_EXCEPTION2(
874+
ErrorInvalidNodeType,
875+
std::string( "Invalid pointRangeNodeType type: " )
876+
.append( _numericalNodeTypeStr( data3DHeader.pointFields.pointRangeNodeType ) ) );
832877
};
833878

834879
if ( data3DHeader.pointFields.cartesianXField )
@@ -885,6 +930,11 @@ namespace e57
885930
return FloatNode( imf_, 0.0, PrecisionDouble, angleMin, angleMax );
886931
}
887932
}
933+
934+
throw E57_EXCEPTION2(
935+
ErrorInvalidNodeType,
936+
std::string( "Invalid angleNodeType type: " )
937+
.append( _numericalNodeTypeStr( data3DHeader.pointFields.angleNodeType ) ) );
888938
};
889939

890940
if ( data3DHeader.pointFields.sphericalAzimuthField )

test/src/RandomNum.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ namespace
1515
// Use a uniform distribution [0, 1].
1616
// For explanation of second param, see:
1717
// https://en.cppreference.com/w/cpp/numeric/random/uniform_real_distribution
18-
static std::uniform_real_distribution<> dis(
19-
0, std::nextafter( 1, std::numeric_limits<float>::max() ) );
18+
static std::uniform_real_distribution<float> dis(
19+
0.0f, std::nextafter( 1.0f, std::numeric_limits<float>::max() ) );
2020
}
2121

2222
namespace Random

0 commit comments

Comments
 (0)