"painting/qpathclipper.cpp", line 1643.30: 1540-0274 (S) The name lookup for "fuzzyCompare" did not find a declaration.
"painting/qpathclipper.cpp", line 1643.30: 1540-1292 (I) Static declarations are not considered for a function call if the function is not qualified.
I'm trying to compile Qt 4.5.0 on xlC 9.0.0.4a, and getting the above compiler message for the following code:
static bool fuzzyCompare(qreal a, qreal b)
{
return qFuzzyCompare(a, b);
}
template <typename InputIterator>
InputIterator qFuzzyFind(InputIterator first, InputIterator last, qreal val)
{
while (first != last && !fuzzyCompare(qreal(*first), qreal(val))) //line 1643
++first;
return first;
}
A function can be declared as static function by placing the static keyword before the function name. Now, if the above code is compiled then an error is obtained i.e “undefined reference to staticFunc()”. This happens as the function staticFunc() is a static function and it is only visible in its object file.
You can't call a function without declaring it first. It's how it works in C++..
The compiler will then reject the definition of base() since it doesn't match the preceding declaration.
A static method provides NO reference to an instance of its class (it is a class method) hence, no, you cannot call a non-static method inside a static one.
The "static" keyword is in error here, fuzzyCompare should be declared just
bool fuzzyCompare(qreal a, qreal b)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With