Skip to content

Commit 42067de

Browse files
irasaothms
authored andcommitted
use union to remove warning (issue 105). (IfcOpenShell#108)
1 parent 2401335 commit 42067de

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

src/ifcgeomserver/IfcGeomServer.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,17 @@
4646

4747
using namespace boost;
4848

49+
template <typename T>
50+
union data_field {
51+
char buffer[sizeof(T)];
52+
T value;
53+
};
54+
4955
template <typename T>
5056
T sread(std::istream& s) {
51-
char buf[sizeof(T)];
52-
s.read(buf, sizeof(T));
53-
return *((T*)buf);
57+
data_field<T> data;
58+
s.read(data.buffer, sizeof(T));
59+
return data.value;
5460
}
5561

5662
template <>

0 commit comments

Comments
 (0)