473,881 Members | 1,661 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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,p ointer) \
{ \
long task$; \
if (task == FOO) { \
task$ = ZERO); \
} else task$ = task; \
switch (task$) {

etc.

Dec 4 '06 #1
17 10459
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,p ointer) \
{ \
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**********@h otmail.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.ne t 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,p ointer) \
{ \
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,p ointer) \
{ \
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**********@h otmail.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)gma il.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,p ointer) \
{ \
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

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
21338
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"); System.out.println(m.replaceAll("\\$_POST")); Works fine, prints:
29
22221
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 replacing the period for some attribute references, as in obj$func() versus obj.func(), and too many programs treat that as an email address and screw it up. Also the S in the symbol $ reminds one of the S in $elf. Can people from outside the...
3
2269
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 value, complete with the dollar sign and commas for the thousands separator (and an optional leading minus sign for negative values). For instance: $1,234.56. One restriction I have to live with is that I can't change the schema of the table or...
2
3050
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 would like to write this: {$var} where var ofcourse will be replaced by the real var however I'm having trouble with the dollar sign I do escape the it though, my regexp:
2
2326
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 always add a dollar sign next to any existing dollar sign. so that dollar signs are always served in pairs The content is residing in a MySQL database. Thanks for any help that can be offered.
14
9863
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 vs. onclick? Is onclick only an attribute thing?
29
19323
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 site and so far doing this has saved about 8KB of javascript (lots of ajax/dynamic elements). I just
4
4413
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 provided the only direct, on-topic reply. He wrote:
0
9926
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11094
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10715
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10811
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9550
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7952
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7105
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5780
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
3221
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.