Commit 84486a42 authored by Henry's avatar Henry
Browse files

int32: Add IO operators for long on 32bit OS

On 32bit OSs long is not unambiguously int32_t (or int64_t) causing
problems for IO operator resolution.  This problem is avoided by
explicitly defining the following operators:
parent 6ef4cd18
......@@ -69,6 +69,15 @@ bool read(const char*, int32_t&);
Istream& operator>>(Istream&, int32_t&);
Ostream& operator<<(Ostream&, const int32_t);
// On 32bit OSs long is not unambiguously int32_t (or int64_t) causing problems
// for IO operator resolution.
// This problem is avoided by explicitly defining the following operators:
#if WM_ARCH_OPTION == 32
Istream& operator>>(Istream&, long&);
Ostream& operator<<(Ostream&, const long);
#endif
//- Template specialization for pTraits<int32_t>
template<>
class pTraits<int32_t>
......
......@@ -104,4 +104,18 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const int32_t i)
}
#if WM_ARCH_OPTION == 32
Foam::Istream& Foam::operator>>(Istream& is, long& i)
{
return operator>>(is, reinterpret_cast<int32_t&>(i));
}
Foam::Ostream& Foam::operator<<(Ostream& os, const long i)
{
os << int32_t(i);
return os;
}
#endif
// ************************************************************************* //
......@@ -6,7 +6,8 @@ RANLIB = ranlib
CPP = cpp
LD = ld
GFLAGS = -D$(WM_ARCH) -DWM_$(WM_PRECISION_OPTION) -DWM_LABEL_SIZE=$(WM_LABEL_SIZE)
GFLAGS = -D$(WM_ARCH) -DWM_ARCH_OPTION=$(WM_ARCH_OPTION) \
-DWM_$(WM_PRECISION_OPTION) -DWM_LABEL_SIZE=$(WM_LABEL_SIZE)
GINC =
GLIBS = -lm
GLIB_LIBS =
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment