1. msvc creates different symbols for a variable declared in
a namespace scope and (the same variable) in a class method
scope. That is,
// util.cpp
namespace GiNaC {
extern const ex _ex0; // [1]
}
// ex.h
namespace GiNaC {
class ex {
public:
bool is_zero() {
extern const ex _ex0;
// mangled name of _ex0 is different that of [1]
}
};
}
2. The mangled names for cv-qualified and cv-unqualified versions
of a type are different (which violates the requirements stated
in [basic.type.qualifier])
These msvc's "features" cause linking failures due to unresolved
external symbols.
Solution:
1. Declare variables (_ex0) in the GiNaC namespace scope (for msvc only).
2. Add corresponding cv-qualifier(s).
#include <stack>
namespace GiNaC {
+#ifdef _MSC_VER
+ // MSVC produces a different symbol for _ex0 when it is declared inside
+ // ex::is_zero() than when it is declared at top level as follows
+ extern const ex _ex0;
+#endif
/** Helper class to initialize the library. There must be one static object
* of this class in every object file that makes use of our flyweights in
// comparison
int compare(const ex & other) const;
bool is_equal(const ex & other) const;
- bool is_zero() const { extern const ex _ex0; return is_equal(_ex0); }
+ bool is_zero() const {
+#ifndef _MSC_VER
+ extern const ex _ex0;
+#endif
+ return is_equal(_ex0);
+ }
bool is_zero_matrix() const;
// symmetry
}
}
-extern numeric* _num_1_p;
+extern const numeric* _num_1_p;
static ex make_minus_expr(const exvector& args)
{
return e;
}
-extern numeric* _num_1_p;
-extern ex _ex0;
+extern const ex _ex0;
/// unary_expr: [+-] expression
ex parser::parse_unary_expr()