[C++] How to fetch the process id of the currently active C++ file?
I tried this:
Code:
#include <iostream> Code:
anisha@linux-trra:~/> ps -f How to solve this? |
a cpp files is not runnable, it is not a process. It will be compiled, and linked together with other compiled files and the result will be one single program. if you execute this process it will get a process id. In a multithreaded environment all the running threads will get also an id, but a source file (like your cpp) will never have a process id.
|
Quote:
of that cpp file! I actually wanted to fetch the file name and was thinking of extracting it from output of ps! :doh: The simpler way is __FILE__! :) http://gcc.gnu.org/onlinedocs/cpp/St...ed-Macros.html |
All times are GMT -5. The time now is 04:37 AM. |