From 38e5a2313b2e1e6ef2a341a0fd3c707335600a3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Wed, 23 Aug 2023 10:16:01 +0200 Subject: [PATCH] Get rid of some old c style casts --- src/OpenMesh/Core/IO/BinaryHelper.cc | 32 ++++++++++++++-------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/OpenMesh/Core/IO/BinaryHelper.cc b/src/OpenMesh/Core/IO/BinaryHelper.cc index d5386e98..c30d5452 100644 --- a/src/OpenMesh/Core/IO/BinaryHelper.cc +++ b/src/OpenMesh/Core/IO/BinaryHelper.cc @@ -74,7 +74,7 @@ namespace IO { short int read_short(FILE* _in, bool _swap) { union u1 { short int s; unsigned char c[2]; } sc; - fread((char*)sc.c, 1, 2, _in); + fread(reinterpret_cast(sc.c), 1, 2, _in); if (_swap) std::swap(sc.c[0], sc.c[1]); return sc.s; } @@ -86,7 +86,7 @@ short int read_short(FILE* _in, bool _swap) int read_int(FILE* _in, bool _swap) { union u2 { int i; unsigned char c[4]; } ic; - fread((char*)ic.c, 1, 4, _in); + fread(reinterpret_cast(ic.c), 1, 4, _in); if (_swap) { std::swap(ic.c[0], ic.c[3]); std::swap(ic.c[1], ic.c[2]); @@ -101,7 +101,7 @@ int read_int(FILE* _in, bool _swap) float read_float(FILE* _in, bool _swap) { union u3 { float f; unsigned char c[4]; } fc; - fread((char*)fc.c, 1, 4, _in); + fread(reinterpret_cast(fc.c), 1, 4, _in); if (_swap) { std::swap(fc.c[0], fc.c[3]); std::swap(fc.c[1], fc.c[2]); @@ -116,7 +116,7 @@ float read_float(FILE* _in, bool _swap) double read_double(FILE* _in, bool _swap) { union u4 { double d; unsigned char c[8]; } dc; - fread((char*)dc.c, 1, 8, _in); + fread(reinterpret_cast(dc.c), 1, 8, _in); if (_swap) { std::swap(dc.c[0], dc.c[7]); std::swap(dc.c[1], dc.c[6]); @@ -131,7 +131,7 @@ double read_double(FILE* _in, bool _swap) short int read_short(std::istream& _in, bool _swap) { union u1 { short int s; unsigned char c[2]; } sc; - _in.read((char*)sc.c, 2); + _in.read(reinterpret_cast(sc.c), 2); if (_swap) std::swap(sc.c[0], sc.c[1]); return sc.s; } @@ -143,7 +143,7 @@ short int read_short(std::istream& _in, bool _swap) int read_int(std::istream& _in, bool _swap) { union u2 { int i; unsigned char c[4]; } ic; - _in.read((char*)ic.c, 4); + _in.read(reinterpret_cast(ic.c), 4); if (_swap) { std::swap(ic.c[0], ic.c[3]); std::swap(ic.c[1], ic.c[2]); @@ -158,7 +158,7 @@ int read_int(std::istream& _in, bool _swap) float read_float(std::istream& _in, bool _swap) { union u3 { float f; unsigned char c[4]; } fc; - _in.read((char*)fc.c, 4); + _in.read(reinterpret_cast(fc.c), 4); if (_swap) { std::swap(fc.c[0], fc.c[3]); std::swap(fc.c[1], fc.c[2]); @@ -173,7 +173,7 @@ float read_float(std::istream& _in, bool _swap) double read_double(std::istream& _in, bool _swap) { union u4 { double d; unsigned char c[8]; } dc; - _in.read((char*)dc.c, 8); + _in.read(reinterpret_cast(dc.c), 8); if (_swap) { std::swap(dc.c[0], dc.c[7]); std::swap(dc.c[1], dc.c[6]); @@ -192,7 +192,7 @@ void write_short(short int _i, FILE* _out, bool _swap) union u1 { short int s; unsigned char c[2]; } sc; sc.s = _i; if (_swap) std::swap(sc.c[0], sc.c[1]); - fwrite((char*)sc.c, 1, 2, _out); + fwrite(reinterpret_cast(sc.c), 1, 2, _out); } @@ -207,7 +207,7 @@ void write_int(int _i, FILE* _out, bool _swap) std::swap(ic.c[0], ic.c[3]); std::swap(ic.c[1], ic.c[2]); } - fwrite((char*)ic.c, 1, 4, _out); + fwrite(reinterpret_cast(ic.c), 1, 4, _out); } @@ -222,7 +222,7 @@ void write_float(float _f, FILE* _out, bool _swap) std::swap(fc.c[0], fc.c[3]); std::swap(fc.c[1], fc.c[2]); } - fwrite((char*)fc.c, 1, 4, _out); + fwrite(reinterpret_cast(fc.c), 1, 4, _out); } @@ -239,7 +239,7 @@ void write_double(double _d, FILE* _out, bool _swap) std::swap(dc.c[2], dc.c[5]); std::swap(dc.c[3], dc.c[4]); } - fwrite((char*)dc.c, 1, 8, _out); + fwrite(reinterpret_cast(dc.c), 1, 8, _out); } @@ -251,7 +251,7 @@ void write_short(short int _i, std::ostream& _out, bool _swap) union u1 { short int s; unsigned char c[2]; } sc; sc.s = _i; if (_swap) std::swap(sc.c[0], sc.c[1]); - _out.write((char*)sc.c, 2); + _out.write(reinterpret_cast(sc.c), 2); } @@ -266,7 +266,7 @@ void write_int(int _i, std::ostream& _out, bool _swap) std::swap(ic.c[0], ic.c[3]); std::swap(ic.c[1], ic.c[2]); } - _out.write((char*)ic.c, 4); + _out.write(reinterpret_cast(ic.c), 4); } @@ -281,7 +281,7 @@ void write_float(float _f, std::ostream& _out, bool _swap) std::swap(fc.c[0], fc.c[3]); std::swap(fc.c[1], fc.c[2]); } - _out.write((char*)fc.c, 4); + _out.write(reinterpret_cast(fc.c), 4); } @@ -298,7 +298,7 @@ void write_double(double _d, std::ostream& _out, bool _swap) std::swap(dc.c[2], dc.c[5]); std::swap(dc.c[3], dc.c[4]); } - _out.write((char*)dc.c, 8); + _out.write(reinterpret_cast(dc.c), 8); }