473,399 Members | 3,401 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

dollar sign in macros

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
17 10183
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
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
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
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
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
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
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
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

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
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
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Ding | last post by:
Hello, I've got a problem with the regular expression api. To illustrate the problem i've made a little example: Matcher m=Pattern.compile("test").matcher("this is a test not");...
29
by: Mark Hahn | last post by:
We are considering switching to the dollar sign ($) for self, instead of the period ( . ) we are using now in Prothon. Ruby uses the at-sign (@) for self, but our new usage of self also includes...
3
by: mark.a.lemoine | last post by:
I need to be selecting records based on the value of a string-format currency value. Specifically, I have a table with a field of type varchar(50). Stored in this field is a dollar-formatted...
2
by: Yorian | last post by:
I just started to try regexps in php and I didn't have too many problems, however I found a few when trying to build a templte engine. The first one is found is the dollar sign. In my template I...
2
by: johnson4 | last post by:
Im wanting to display a dollar sign on my wap application, which requires that the cell phone is served with $$ to display $. Therefor I'm trying to find an easy way, in my php code, that will...
14
by: gimme_this_gimme_that | last post by:
What is going on here with the dollar signs and parenthesis? $(document).ready(function(){ $("li").behavior("click",function(){ $(this).load(menu.html"); }); }); And when do you use click...
29
by: Nick | last post by:
I've seen a few frameworks use the following: function $(id) { return document.getElementById(id); } Then to use: $('something').innerHTML = 'blah'; I'm just trying to roll this out to my...
4
by: Robbie Hatley | last post by:
Some months ago, I'd asked this group: "Backtick, at-sign, dollar-sign: legal in source?" I got 20 replies, most of which were off-topic and did not answer the question. Keith Thompson...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.