#include <iostream>
#include <cmath>
-using namespace std;
template<class T> inline T Abs (const T &a){return a <0 ? -a : a;}
template<class T> inline void Echange (T& a,T& b) {T c=a;a=b;b=c;}
//le type Z des nombres entiers relatifs
//=========
-typedef long int Z;
+// 64-bit porting: "long" replaced with "int".
+// On 64-bit, C++ long type is 8 byte long. MEFISTO2D C code calls several Fortran subroutines passing
+// arguments of this type, however Fortran knows nothing about changed size of arguments,
+// therefore stack gets corrupted. With "int" used instead of "long", Fortran calls from C do no harm to the stack
+// After this modification, behavior on 32-bit platforms does not change: on all platforms supported by
+// SALOME 3, "int" and "long" have the same size of 4 bytes.
+//========
+//typedef long int Z;
+typedef int Z;
//le type R des nombres "reels"
//=========
//============
class R2
{
- friend ostream& operator << (ostream& f, const R2 & P)
+ friend std::ostream& operator << (std::ostream& f, const R2 & P)
{ f << P.x << ' ' << P.y ; return f; }
- friend istream& operator >> (istream& f, R2 & P)
+ friend std::istream& operator >> (std::istream& f, R2 & P)
{ f >> P.x >> P.y ; return f; }
- friend ostream& operator << (ostream& f, const R2 * P)
+ friend std::ostream& operator << (std::ostream& f, const R2 * P)
{ f << P->x << ' ' << P->y ; return f; }
- friend istream& operator >> (istream& f, R2 * P)
+ friend std::istream& operator >> (std::istream& f, R2 * P)
{ f >> P->x >> P->y ; return f; }
public:
//============
class R3
{
- friend ostream& operator << (ostream& f, const R3 & P)
+ friend std::ostream& operator << (std::ostream& f, const R3 & P)
{ f << P.x << ' ' << P.y << ' ' << P.z ; return f; }
- friend istream& operator >> (istream& f, R3 & P)
+ friend std::istream& operator >> (std::istream& f, R3 & P)
{ f >> P.x >> P.y >> P.z ; return f; }
- friend ostream& operator << (ostream& f, const R3 * P)
+ friend std::ostream& operator << (std::ostream& f, const R3 * P)
{ f << P->x << ' ' << P->y << ' ' << P->z ; return f; }
- friend istream& operator >> (istream& f, R3 * P)
+ friend std::istream& operator >> (std::istream& f, R3 * P)
{ f >> P->x >> P->y >> P->z ; return f; }
public:
//============
class R4: public R3
{
- friend ostream& operator <<(ostream& f, const R4 & P )
+ friend std::ostream& operator <<(std::ostream& f, const R4 & P )
{ f << P.x << ' ' << P.y << ' ' << P.z << ' ' << P.omega; return f; }
friend istream& operator >>(istream& f, R4 & P)
{ f >> P.x >> P.y >> P.z >> P.omega ; return f; }
- friend ostream& operator <<(ostream& f, const R4 * P )
+ friend std::ostream& operator <<(std::ostream& f, const R4 * P )
{ f << P->x << ' ' << P->y << ' ' << P->z << ' ' << P->omega; return f; }
friend istream& operator >>(istream& f, R4 * P)
{ f >> P->x >> P->y >> P->z >> P->omega ; return f; }