Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Static declarations are not considered for a function call if the function is not qualified

Tags:

c++

xlc

"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;
}
like image 240
Walter Nissen Avatar asked Jul 07 '09 18:07

Walter Nissen


People also ask

Can a function be declared static?

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.

Can we call a function without declaration?

You can't call a function without declaring it first. It's how it works in C++..

What will happen if the function definition does not match the function declaration?

The compiler will then reject the definition of base() since it doesn't match the preceding declaration.

Can a static function call a non-static function in C?

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.


1 Answers

The "static" keyword is in error here, fuzzyCompare should be declared just

bool fuzzyCompare(qreal a, qreal b)
like image 102
Walter Nissen Avatar answered Oct 06 '22 01:10

Walter Nissen