GNOME Bugzilla – Bug 154880
if "using namespace" used, call of a static member function in C++ is not recognized or recognized wrong
Last modified: 2013-12-24 18:59:39 UTC
call of a static member function in C++ is not recognized if "using namespace" used or if it was called inside the namespace. In the example 1 code below the call in main() to MyClass::fun() is not found by doxygen 1.3.9. In this case this call in main is not recognized, of course the "referency by" section for MyClass::fun is empty. There is no problem if I write explicity namespace for the call. Example 1 ----------------------------------------------------- namespace TEST { class MyClass { public: /** * Do nothing. * @return 0. */ static int fun () { return 0; }; }; } using namespace TEST; /** * Main function. */ int main () { return MyClass::fun(); } ----------------------------------------------------- ----------------------------------------------------- namespace TEST { class MyClass { public: /** * Do nothing. * @return 0. */ static int fun () { return 0; }; }; } using namespace TEST; /** * Main function. */ int main () { return TEST::MyClass::fun(); //in this way it works } ----------------------------------------------------- if we have in this namespace "stand-alone" function with the same name to we get link to this separate function, however we use class name explicity in this call (example 2) ----------------------------------------------------- namespace TEST { int fun (int par) { return par; }; //this function will be //linked with call in main class MyClass { public: /** * Do nothing. * @return 0. */ static int fun () { return 0; }; }; } using namespace TEST; /** * Main function. */ int main () { return MyClass::fun(); } -----------------------------------------------------
Should work in 1.3.9.1. Can you confirm?
Example 1 works with 1.3.9.1. Example 2 not. Here is a variant of example 1, that is doesn't work with 1.3.9.1 Example 3 ------------------------------------------------------------------- namespace TEST { class MyClass { public: /** * Do nothing. * @return par. */ static int fun(int par) { return par; }; }; namespace TEST2 { class MyClass2 { public: static int fun2() {return 0;} }; } } using namespace TEST; using namespace TEST::TEST2; /** * Main function. */ int _tmain(int argc, _TCHAR* argv[]) { int i = MyClass2::fun2(); // here the link is generated properly return MyClass::fun(i); // here not } ---------------------------------------------------------- if I change "using namespace" to another order, in this case MyClass::fun(i) will be recognized and MyClass2::fun2() not.
The same problem occurs when documenting java code: statically called functions do not have a filled 'referenced by' section myFunc1 { double x = myClass.myFunc2 => empty 'referenced by' section for myFunc2 } myFunc1 { myClass obj = new myClass() double x = obj.myFunc2 => filled 'referenced by' section for myFunc2 }
This bug's version was set to "latest". Since this is a moving target, I changed it to 1.5.3-SVN. If you believe this has already been fixed, then please change the status accordingly.
I looked with version 1.8.5 to the 3 original examples. Examples 1 and 2 are OK Example 3 still has a problem. When the code is as specified in the Source code the MyClass2::fun2 is not hyper linked; when interchanging the 2 using namespace statements MyClass2::fun2 is hyper linked. MyClass::fun is hyper linked in both cases. (same accounts for the references in tmain).
Created attachment 253064 [details] Used example3 and config file Example3 plus configuration file
Confirmed. Should be fixed in the next GIT update.
This bug was previously marked ASSIGNED, which means it should be fixed in doxygen version 1.8.6. Please verify if this is indeed the case. Reopen the bug if you think it is not fixed and please include any additional information that you think can be relevant (preferrably in the form of a self-contained example).