Hello! Upgraded to gcc 4.2.1 and ran into a following issue: test case: #include <iostream> #include <sstream> #include <sys/types.h> #include <linux/unistd.h> #include <errno.h> // Declare the gettid syscall. _syscall0(pid_t, gettid); int main() { std::cout<<"Test for gettid: "<<std::gettid()<<endl; return 0; } It works on gcc 3.6. Incluede all the proper header according to man pages, but compiler returns: getid.cpp:10: error: ‘gettid’ has not been declared getid.cpp:10: error: expected constructor, destructor, or type conversion before ‘;’ token getid.cpp: In function ‘int main()’: getid.cpp:16: error: ‘gettid’ was not declared in this scope Sergey
Created attachment 14296 [details] test case
And this is not a bug with GCC or libstdc++ as gettid is an GNU libc extension. Try using gettid instead of std::gettid. Doing that and qualifying endl with std:: allows for this program to compile.
Why should gettid be in namespace std? It's not a standard C++ function, so the header file declares it to be in the global namespace. W.
(In reply to comment #3) > Why should gettid be in namespace std? It's not a standard C++ function, > so the header file declares it to be in the global namespace. > > W. > (In reply to comment #3) > Why should gettid be in namespace std? It's not a standard C++ function, > so the header file declares it to be in the global namespace. > > W. > Ok. That's just the test. I can remove namespace completely: #include <sys/types.h> #include <linux/unistd.h> #include <errno.h> int main() { gettid(); return 0; } Same result. Actually I figured it will bring up questions, sor
Ok. That's just the test. I can remove namespace completely: #include <sys/types.h> #include <linux/unistd.h> #include <errno.h> int main() { gettid(); return 0; } Same result. Actually I figured it will bring up questions, sorry
Try asking for help on some Linux mailing list, because gettid is (or was) a Linux extension, actually. In any case, what is available or not on such system headers has nothing to do with GCC.