diff --git a/src/OpenFOAM/primitives/ints/int32/int32.H b/src/OpenFOAM/primitives/ints/int32/int32.H index c2a3097ab6..2bf5e799d2 100644 --- a/src/OpenFOAM/primitives/ints/int32/int32.H +++ b/src/OpenFOAM/primitives/ints/int32/int32.H @@ -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 template<> class pTraits diff --git a/src/OpenFOAM/primitives/ints/int32/int32IO.C b/src/OpenFOAM/primitives/ints/int32/int32IO.C index d491e236a4..ae4a2a1d64 100644 --- a/src/OpenFOAM/primitives/ints/int32/int32IO.C +++ b/src/OpenFOAM/primitives/ints/int32/int32IO.C @@ -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(i)); +} + +Foam::Ostream& Foam::operator<<(Ostream& os, const long i) +{ + os << int32_t(i); + return os; +} +#endif + + // ************************************************************************* // diff --git a/wmake/rules/General/general b/wmake/rules/General/general index ecbe83a14e..062c704f13 100644 --- a/wmake/rules/General/general +++ b/wmake/rules/General/general @@ -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 =