Re: compile time user name

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Mohanlal Jangir wrote:

> Does any gcc attribute exist to get user name at compile time? For example
> 
> int main( )
> {
>     printf("*** version info ***\n");
>     printf("DATE = %s\n", __DATE__);
>     printf("TIME = %s\n", __TIME__);
>     printf("USER = %s\n", ??????);
>     return 0;
> }
> 
> Any way to get USER info ??

Not that I'm aware of, but you can certainly achieve this with the
preprocessor:

gcc foo.c -D__USER__=\"$(id -un)\"

Brian

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux