Topic: Proposal: predefined __user__ macro
Author: "Greg Brewer" <nospam.greg@brewer.net>
Date: Thu, 22 Feb 2001 20:15:41 GMT Raw View
I would to propose that C++ compilers predefine __user__ macro. The macro
would be predefined to something -- hopefully the current logon name if
there is such an animal -- in the same way that __date__, etc are now
predefined. In a group development effort, this would allow me to write a
section of code that applies only to me.
Example,
#if __user__ == greg
PrintDebugInfo("C:\\debug.txt","reached point 32");
#endif
Now when I compile this, I get the debug call included in my routine. If I
fail to remove the line and it makes it into the shipping code base, it
won't get included because that machine isn't named greg.
Greg
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html ]
[ Note that the FAQ URL has changed! Please update your bookmarks. ]
Author: "Andrea Ferro" <AndreaF@UrkaDVD.it>
Date: Fri, 23 Feb 2001 00:51:24 GMT Raw View
"Greg Brewer" <nospam.greg@brewer.net> wrote in message
news:973rte$2bnv$1@news.hal-pc.org...
> I would to propose that C++ compilers predefine __user__ macro. The macro
> would be predefined to something -- hopefully the current logon name if
> there is such an animal -- in the same way that __date__, etc are now
> predefined. In a group development effort, this would allow me to write a
> section of code that applies only to me.
>
> Example,
>
> #if __user__ == greg
> PrintDebugInfo("C:\\debug.txt","reached point 32");
> #endif
>
> Now when I compile this, I get the debug call included in my routine. If I
> fail to remove the line and it makes it into the shipping code base, it
> won't get included because that machine isn't named greg.
__date__ and __time__ do make sense since they change. But __user__ maybe not.
What's wrong with the idea of setting up your own machine to define a __user__
kind of macro in the command line? If your compiler does not support "account
based" settings but only "machine wide" settings, it probably have some feature
that let you specify command line options in a file or in the environment. The
rest is just log-on script tricks.
Andrea Ferro
---------
Brainbench C++ Master. Scored higher than 97% of previous takers
Scores: Overall 4.46, Conceptual 5.0, Problem-Solving 5.0
More info http://www.brainbench.com/transcript.jsp?pid=2522556
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html ]
[ Note that the FAQ URL has changed! Please update your bookmarks. ]
Author: "James Kuyper Jr." <kuyper@wizard.net>
Date: Fri, 23 Feb 2001 06:46:58 GMT Raw View
Greg Brewer wrote:
>
> I would to propose that C++ compilers predefine __user__ macro. The macro
> would be predefined to something -- hopefully the current logon name if
> there is such an animal -- in the same way that __date__, etc are now
> predefined. In a group development effort, this would allow me to write a
> section of code that applies only to me.
>
> Example,
>
> #if __user__ == greg
> PrintDebugInfo("C:\\debug.txt","reached point 32");
> #endif
>
> Now when I compile this, I get the debug call included in my routine. If I
> fail to remove the line and it makes it into the shipping code base, it
> won't get included because that machine isn't named greg.
"user" is an OS-dependent issue, with properly OS-specific solutions.
Something like the following will work in some form on most Unices I'm
familiar with; a variant will work in a DOS window on most Windows
platforms:
cc -Duser=$USER file.c
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html ]
[ Note that the FAQ URL has changed! Please update your bookmarks. ]
Author: "Greg Brewer" <nospam.greg@brewer.net>
Date: Fri, 23 Feb 2001 14:03:59 CST Raw View
> "user" is an OS-dependent issue, with properly OS-specific solutions.
> Something like the following will work in some form on most Unices I'm
> familiar with; a variant will work in a DOS window on most Windows
> platforms:
>
> cc -Duser=$USER file.c
Works but not very well and gets lost too easily, especially in my .IDE.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html ]
[ Note that the FAQ URL has changed! Please update your bookmarks. ]
Author: "Greg Brewer" <nospam.greg@brewer.net>
Date: Fri, 23 Feb 2001 21:04:31 GMT Raw View
> __date__ and __time__ do make sense since they change. But __user__ maybe
not.
> What's wrong with the idea of setting up your own machine to define a
__user__
> kind of macro in the command line? If your compiler does not support
"account
> based" settings but only "machine wide" settings, it probably have some
feature
> that let you specify command line options in a file or in the environment.
The
> rest is just log-on script tricks.
In my case, we have 3 developers working from a common code base. In the
past, I have tried to set up our development environments to identify us
individually but the effort is lost when some change to the environment
requires us to syncronize environments. In a networked environment, knowing
who is doing the compiling is a useful piece of information.
Greg
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html ]
[ Note that the FAQ URL has changed! Please update your bookmarks. ]
Author: "Andrea Ferro" <AndreaF@UrkaDVD.it>
Date: Sat, 24 Feb 2001 16:18:30 GMT Raw View
"Greg Brewer" <nospam.greg@brewer.net> wrote in message
news:976enh$j0$1@news.hal-pc.org...
...
> In my case, we have 3 developers working from a common code base. In the
> past, I have tried to set up our development environments to identify us
> individually but the effort is lost when some change to the environment
> requires us to syncronize environments. In a networked environment, knowing
> who is doing the compiling is a useful piece of information.
???
Unless when you sync your environment you also sync login name and passwords I
see no way this should void your "individual identification" setup. In a VERY
disperate case the absolute minimum you need is a system with either logon user
name in the environment OR logon scripts capability. If either is true you can
setup things so that everithing is identical for all of you (but logon name).
Andrea Ferro
---------
Brainbench C++ Master. Scored higher than 97% of previous takers
Scores: Overall 4.46, Conceptual 5.0, Problem-Solving 5.0
More info http://www.brainbench.com/transcript.jsp?pid=2522556
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html ]
[ Note that the FAQ URL has changed! Please update your bookmarks. ]
Author: "Greg Brewer" <nospam.greg@brewer.net>
Date: Sun, 25 Feb 2001 14:44:37 GMT Raw View
Forget it; I give up making anymore suggestions.
Greg
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html ]
[ Note that the FAQ URL has changed! Please update your bookmarks. ]
Author: marco@technoboredom.net (Marco Manfredini)
Date: Mon, 26 Feb 2001 20:00:03 GMT Raw View
"Greg Brewer" <nospam.greg@brewer.net> wrote in
<976fca$n1$1@news.hal-pc.org>:
>> "user" is an OS-dependent issue, with properly OS-specific
>> solutions. Something like the following will work in some form on
>> most Unices I'm familiar with; a variant will work in a DOS window
>> on most Windows platforms:
>>
>> cc -Duser=$USER file.c
>
>Works but not very well and gets lost too easily, especially in my
>.IDE.
>
If your IDE calls the compilers executable while building (ie. calls
'cl.exe' or something and not a .DLL containing the compiler
functionality), you might get lucky with a cl.exe proxy which filters
the commandline given by the IDE and inserts an appropriate -
D__USER__=GetUserName() before calling the real compiler.
If the proxy could perform non-standard preprocessing or commandline
translation for different compilers, it would be even more useful...
--
greetings
Marco
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html ]
[ Note that the FAQ URL has changed! Please update your bookmarks. ]
Author: "Walter" <walter6@bumby.com>
Date: Wed, 28 Feb 2001 00:24:32 GMT Raw View
Some make programs will look for macros in the environment, so you could set
an environment variable:
set USERNAME=Greg
and in your makefile, add the line:
-Duser=$(USERNAME)
Greg Brewer wrote in message <973rte$2bnv$1@news.hal-pc.org>...
>I would to propose that C++ compilers predefine __user__ macro. The macro
>would be predefined to something -- hopefully the current logon name if
>there is such an animal -- in the same way that __date__, etc are now
>predefined. In a group development effort, this would allow me to write a
>section of code that applies only to me.
>
>Example,
>
>#if __user__ == greg
> PrintDebugInfo("C:\\debug.txt","reached point 32");
>#endif
>
>Now when I compile this, I get the debug call included in my routine. If I
>fail to remove the line and it makes it into the shipping code base, it
>won't get included because that machine isn't named greg.
>
>Greg
>
>
>---
>[ comp.std.c++ is moderated. To submit articles, try just posting with ]
>[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
>[ --- Please see the FAQ before posting. --- ]
>[ FAQ: http://www.research.att.com/~austern/csc/faq.html ]
>[ Note that the FAQ URL has changed! Please update your bookmarks. ]
>
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html ]
[ Note that the FAQ URL has changed! Please update your bookmarks. ]