Hi g33kz!
I saw some apps, which storred machine hostname at build time. I am coding one project in C, and I want to store machine hostname, where the binary was compiled. I cannot find it. How can I do it? Is there some preprocessor macro or what? I am using gcc.
Thanks
test.c: In function 'main':
test.c:4: error: '__HOSTNAME__' undeclared (first use in this function)
test.c:4: error: (Each undeclared identifier is reported only once
test.c:4: error: for each function it appears in.)
Why would you want to do that?
One very simple solution would be to actually use code-at-compile-time like provided by Lisp macros, however since you want to do it in C, you can either depend on implementation specific defines or just use your own post-processor (perl, M4, whatever language, even C would work).
If using your own pre-processor is overkill, you can always just write a little C application which writes a tiny header file "host-information.h" which is then included where you need these values. You'd just have to make sure to compile and run this application before the rest of the code, however you can easily do that with whatever makefile/build system you have going.