This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: compile time user name
- From: Brian Dessent <brian at dessent dot net>
- To: Mohanlal Jangir <mohanlaljangir at gmail dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Mon, 09 Apr 2007 19:12:08 -0700
- Subject: Re: compile time user name
- References: <58484c0e0704091857j558e1040yd3566a6f9b30e54c@mail.gmail.com>
- Reply-to: gcc-help at gcc dot gnu dot org
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