By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,492 Members | 1,199 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,492 IT Pros & Developers. It's quick & easy.

dollar sign in macros

P: n/a
I've inherited some code where the coder placed dollar signs in
his preprocessor macros. What is the significance of the
dollar signs ($) ?

Example:
#define ALLOCATE(task,pointer) \
{ \
long task$; \
if (task == FOO) { \
task$ = ZERO); \
} else task$ = task; \
switch (task$) {

etc.

Dec 4 '06 #1
Share this Question
Share on Google+
17 Replies


P: n/a
Digital Puer wrote:
I've inherited some code where the coder placed dollar signs in
his preprocessor macros. What is the significance of the
dollar signs ($) ?
I'm not a Standard expert, but I think $ is disallowed in an
identifier:
---
3.1.2 Identifiers
<snip>
An identifier is a sequence of nondigit characters (including the
underscore _ and the lower-case and upper-case letters) and digits. The
first character shall be a nondigit character.
<snip>
---

<OT>
That said, $ does have a special treatment on OpenVMS and maybe other
VAXen systems. I'm not sure what it does however...
</OT>

--
WYCIWYG - what you C is what you get

Dec 4 '06 #2

P: n/a
Hello,
I've inherited some code where the coder placed dollar signs in
his preprocessor macros. What is the significance of the
dollar signs ($) ?

Example:
#define ALLOCATE(task,pointer) \
{ \
long task$; \
if (task == FOO) { \
task$ = ZERO); \
} else task$ = task; \
switch (task$) {

etc.
in your above example, the '$' sign has no special meaning. It's just
used as another character for the variable name, which is called here
"task$". This may be a strange name, but unless I am mistaken, this is
a perfectly valid name.

The coder may have use the "$" sign to define a convention of its own.
Unless you have some documentation (code design, comments in the code
etc.) about this convention, you have to induce it (if one is defined)
from the source you received. Or just you take that "$"-name as it is.

HTH,
Loic.

Dec 4 '06 #3

P: n/a
On 4 Dec 2006 14:03:55 -0800, in comp.lang.c , "Digital Puer"
<di**********@hotmail.comwrote:
>I've inherited some code where the coder placed dollar signs in
his preprocessor macros. What is the significance of the
dollar signs ($) ?
reminds me of the old VAX/VMS system routines/variables.
--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
Dec 4 '06 #4

P: n/a
lo******@gmx.net writes:
in your above example, the '$' sign has no special meaning. It's just
used as another character for the variable name, which is called here
"task$". This may be a strange name, but unless I am mistaken, this is
a perfectly valid name.
Not in ISO C, either C89 or C99. In C99, you can specify a
dollar sign using a universal character name, but it doesn't
*look* like a dollar sign then.
--
"I ran it on my DeathStation 9000 and demons flew out of my nose." --Kaz
Dec 4 '06 #5

P: n/a
Hi Ben,
in your above example, the '$' sign has no special meaning. It's just
used as another character for the variable name, which is called here
"task$". This may be a strange name, but unless I am mistaken, this is
a perfectly valid name.

Not in ISO C, either C89 or C99. In C99, you can specify a
dollar sign using a universal character name, but it doesn't
*look* like a dollar sign then.
Yeah thanks. I had a doubt about this, I just checked out the
standard... I should have used the '-pedantic' flag, when I checked
with my compiler ;-) Which is by no means a proof, BTW... Next time, I
look the standard first, then I post :-D

Cheers,
Loic.

Dec 4 '06 #6

P: n/a
Digital Puer wrote:
I've inherited some code where the coder placed dollar signs in
his preprocessor macros. What is the significance of the
dollar signs ($) ?

Example:
#define ALLOCATE(task,pointer) \
{ \
long task$; \
if (task == FOO) { \
task$ = ZERO); \
} else task$ = task; \
switch (task$) {

etc.
As others have said $ is probably part of the name of
the variable and not allowed in standard C. Some compilers
allow as an extension $ to be part of an identifier name ;
for example gcc.

Dec 4 '06 #7

P: n/a
Digital Puer wrote:
I've inherited some code where the coder placed dollar signs in
his preprocessor macros. What is the significance of the
dollar signs ($) ?

Example:
#define ALLOCATE(task,pointer) \
{ \
long task$; \
if (task == FOO) { \
task$ = ZERO); \
} else task$ = task; \
switch (task$) {

etc.
This is a gcc extension. Other compilers may also have this feature.

Dec 5 '06 #8

P: n/a
Digital Puer <di**********@hotmail.comwrote:
I've inherited some code where the coder placed dollar signs in
his preprocessor macros. What is the significance of the
dollar signs ($) ?
That someone is using a C implementation to preprocess Perl source?
As others have noted the $ is not a valid identifier character. It
should be possible to run this code through the preprocessor with your
implementation and see what it looks like; that may give you a clue as
to what is going on. How that might be accomplished is a question for
a different newsgroup.

--
C. Benson Manica | I *should* know what I'm talking about - if I
cbmanica(at)gmail.com | don't, I need to know. Flames welcome.
Dec 5 '06 #9

P: n/a

santosh wrote:
Digital Puer wrote:
I've inherited some code where the coder placed dollar signs in
his preprocessor macros. What is the significance of the
dollar signs ($) ?

Example:
#define ALLOCATE(task,pointer) \
{ \
long task$; \
if (task == FOO) { \
task$ = ZERO); \
} else task$ = task; \
switch (task$) {

etc.

This is a gcc extension. Other compilers may also have this feature.

The original programmer used Microsoft VC++ to write his C code.
He is a chemist by training, and he is kind of an old guy (about 60).

Another poster said that the code reminded him of VMS code,
so I wonder if the original programmer was doing something
along those lines.

Dec 5 '06 #10

P: n/a
Christopher Benson-Manica <at***@ukato.freeshell.orgwrites:
Digital Puer <di**********@hotmail.comwrote:
>I've inherited some code where the coder placed dollar signs in
his preprocessor macros. What is the significance of the
dollar signs ($) ?

That someone is using a C implementation to preprocess Perl source?
[...]

Not likely. The "identifier" in question was "task$"; Perl would use
"$task".

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Dec 5 '06 #11

P: n/a
In article <11*********************@73g2000cwn.googlegroups.c om>, "Digital Puer" <di**********@hotmail.comwrites:
>
Another poster said that the code reminded him of VMS code,
so I wonder if the original programmer was doing something
along those lines.
I think it's just the programmers habit to use $ in identifiers.
True, VMS C compilers allow $ (and gcc probably to cover programs
written for VMS), but names containing $ in VMS are reserved to the system
vendor (and registered third party software), to make them unique.

So $s in user programs violate both, C and VMS standards.

--
Joseph Huber , Muenchen,Germany: http://www.huber-joseph.de/
Dec 5 '06 #12

P: n/a
Joseph Huber wrote:
>
In article <11*********************@73g2000cwn.googlegroups.c om>, "Digital Puer" <di**********@hotmail.comwrites:

Another poster said that the code reminded him of VMS code,
so I wonder if the original programmer was doing something
along those lines.

I think it's just the programmers habit to use $ in identifiers.
True, VMS C compilers allow $ (and gcc probably to cover programs
written for VMS), but names containing $ in VMS are reserved to the system
vendor (and registered third party software), to make them unique.

So $s in user programs violate both, C and VMS standards.
Whenever I see posted C programs that use reserved identifiers,
it reminds me of a time when I read system header files
to see what proffessional code looked like,
so that I could imitate the style (a misconception on my part).

--
pete
Dec 5 '06 #13

P: n/a
pete <pf*****@mindspring.comwrote:
Whenever I see posted C programs that use reserved identifiers,
it reminds me of a time when I read system header files
to see what proffessional code looked like,
so that I could imitate the style (a misconception on my part).
A misconception in more ways than one, given what some of that
"professional" code looks like :-)

--
C. Benson Manica | I *should* know what I'm talking about - if I
cbmanica(at)gmail.com | don't, I need to know. Flames welcome.
Dec 5 '06 #14

P: n/a
2006-12-05 <wZ**********@vms.mppmu.mpg.de>,
Joseph Huber wrote:
In article <11*********************@73g2000cwn.googlegroups.c om>, "Digital Puer" <di**********@hotmail.comwrites:
>>
Another poster said that the code reminded him of VMS code,
so I wonder if the original programmer was doing something
along those lines.

I think it's just the programmers habit to use $ in identifiers.
True, VMS C compilers allow $ (and gcc probably to cover programs
written for VMS), but names containing $ in VMS are reserved to the system
vendor (and registered third party software), to make them unique.

So $s in user programs violate both, C and VMS standards.
Is \u0024 allowed in identifiers?

Is there a list of what UCNs are and are not allowed in identifiers?
Dec 5 '06 #15

P: n/a
Random832 <ra****@random.yi.orgwrites:
Is \u0024 allowed in identifiers?
No. See C99 6.4.2.1:

3 Each universal character name in an identifier shall designate
a character whose encoding in ISO/IEC 10646 falls into one
of the ranges specified in annex D.59)

0024 isn't in the list in annex D.

I posted the opposite answer earlier in this thread, but I was
wrong. I was confused by 6.4.3, which specifically adds 0024 to
the list of values allowed in a universal-character-name.
Is there a list of what UCNs are and are not allowed in identifiers?
Annex D in the standard gives a complete list.
--
"You call this a *C* question? What the hell are you smoking?" --Kaz
Dec 5 '06 #16

P: n/a
av
On 4 Dec 2006 15:08:58 -0800, Spiros Bousbouras wrote:
>As others have said $ is probably part of the name of
the variable and not allowed in standard C. Some compilers
allow as an extension $ to be part of an identifier name ;
for example gcc.
it seems bcc32 too
Dec 6 '06 #17

P: n/a
Mark McIntyre wrote:
On 4 Dec 2006 14:03:55 -0800, in comp.lang.c , "Digital Puer"
<di**********@hotmail.comwrote:

>>I've inherited some code where the coder placed dollar signs in
his preprocessor macros. What is the significance of the
dollar signs ($) ?


reminds me of the old VAX/VMS system routines/variables.
VMS (not limited to just the vax version) uses the dollar
sign in it's system routines as a seperator from the
"service" and the function parts of the name. The names
look something like (made up names) "sys$open", "str$compare",
"pascal$foobar", etc.

The dollar sign isn't really tied to system routines,
you can actually use them in your own programs,
but you take the chance of overlapping with some existing
VMS variables/functions, so it's not really a good idea.

----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Dec 7 '06 #18

This discussion thread is closed

Replies have been disabled for this discussion.