473,508 Members | 2,509 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

About Macro

Hi All

I Have Quation About Macro's plz help

why do we have # symbol before any macro line #define STOP 0 ...

why con't we use the any other symbol like $, @,,

plz answer if any one knows reason.

Thanks & Regards
Remo

Mar 27 '06 #1
11 1546
"Remo" <re*******@gmail.com> writes:
Hi All I Have Quation About Macro's plz help why do we have # symbol before any macro line #define STOP 0 ... why con't we use the any other symbol like $, @,, plz answer if any one knows reason.

Convention.

<OT>
Or, under Unix:

sed 's/^@/#/' < program.at > program.c
</OT>

--
Chris.
Mar 27 '06 #2
Remo wrote:
Hi All
I Have Quation About Macro's plz help

why do we have # symbol before any macro line #define STOP 0 ...
why con't we use the any other symbol like $, @,,

plz answer if any one knows reason.


Thats simply the way the C preprocessor works. It scans the source file
for lines that begin with the '#' character and takes the rest of that
line as it's directive.

If you really want to use someother character, feel free to modify the
source of any free cpp implementation or write your custom preprocessor
as a plugin replacement, but it that case, your programs will no longer
be C programs.

Mar 27 '06 #3
Remo wrote:
Hi All

I Have Quation About Macro's plz help

why do we have # symbol before any macro line #define STOP 0 ...

why con't we use the any other symbol like $, @,,


We can!

??=include <stdio.h>
??=define POUND_SIGN "Octothorpe"
int main(void) {
printf(POUND_SIGN " is unnecessary!\n");
return 0;
}

--
Eric Sosman
es*****@acm-dot-org.invalid
Mar 27 '06 #4
Wow! this is strange! Is it an anomaly or a loophole?
Cant we use #define to redefine the symbol #??

Regards,

Eric Sosman wrote:
Remo wrote:
Hi All

I Have Quation About Macro's plz help

why do we have # symbol before any macro line #define STOP 0 ...

why con't we use the any other symbol like $, @,,


We can!

??=include <stdio.h>
??=define POUND_SIGN "Octothorpe"
int main(void) {
printf(POUND_SIGN " is unnecessary!\n");
return 0;
}

--
Eric Sosman
es*****@acm-dot-org.invalid


Mar 27 '06 #5
Naresh wrote:
Wow! this is strange! Is it an anomaly or a loophole?
Please don't top-post.

Eric had said:
??=include <stdio.h>
??=define POUND_SIGN "Octothorpe"
int main(void) {
printf(POUND_SIGN " is unnecessary!\n");
return 0;


It's not an anomaly [1] nor is it a loophole. It's a trigraph.
Cant we use #define to redefine the symbol #??


No, we can't. #define can only define macros with names which are,
er, names.

[1] Well, you /could/ say trigraphs-as-a-whole count as an anomoly.

--
Chris "x.f(y) == f(x, y) == (x, y).f" Dollin
The shortcuts are all full of people using them.
Mar 27 '06 #6
On 2006-03-27, Naresh <na**********@gmail.com> wrote:
Wow! this is strange! Is it an anomaly or a loophole?
Cant we use #define to redefine the symbol #??


http://publications.gbdirect.co.uk/c...abet_of_c.html

LOL
Mar 27 '06 #7
On 2006-03-27, Chris Dollin <ke**@hpl.hp.com> wrote:
Naresh wrote:
Wow! this is strange! Is it an anomaly or a loophole?


Please don't top-post.

Eric had said:
??=include <stdio.h>
??=define POUND_SIGN "Octothorpe"
int main(void) {
printf(POUND_SIGN " is unnecessary!\n");
return 0;


It's not an anomaly [1] nor is it a loophole. It's a trigraph.
Cant we use #define to redefine the symbol #??


No, we can't. #define can only define macros with names which are,
er, names.

[1] Well, you /could/ say trigraphs-as-a-whole count as an anomoly.


Digraphs are much better. %:define ...
Mar 27 '06 #8
"Remo" <re*******@gmail.com> writes:
I Have Quation About Macro's plz help

why do we have # symbol before any macro line #define STOP 0 ...

why con't we use the any other symbol like $, @,,

plz answer if any one knows reason.


Because that's how the language syntax is defined. Why would you want
to use a different symbol?

--
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.
Mar 27 '06 #9
Keith Thompson wrote:
"Remo" <re*******@gmail.com> writes:
I Have Quation About Macro's plz help

why do we have # symbol before any macro line #define STOP 0 ...

why con't we use the any other symbol like $, @,,

plz answer if any one knows reason.

Because that's how the language syntax is defined. Why would you want
to use a different symbol?


I think Remo's question is quite clear and I'm surprised by all strange
answers. Let me rephrase the question as I interpret it:

Is there any particular reason why the number sign was chosen as a
prefix for preprocessor directives? Tradition?
August

--
I am the "ILOVEGNU" signature virus. Just copy me to your
signature. This email was infected under the terms of the GNU
General Public License.
Mar 28 '06 #10
On 2006-03-28, August Karlstrom <fu********@comhem.se> wrote:
Keith Thompson wrote:
"Remo" <re*******@gmail.com> writes:
I Have Quation About Macro's plz help

why do we have # symbol before any macro line #define STOP 0 ...

why con't we use the any other symbol like $, @,,

plz answer if any one knows reason.

Because that's how the language syntax is defined. Why would you want
to use a different symbol?


I think Remo's question is quite clear and I'm surprised by all strange
answers. Let me rephrase the question as I interpret it:

Is there any particular reason why the number sign was chosen as
a prefix for preprocessor directives? Tradition?


It was available. About the only symbols in ASCII that aren't used for
SOMETHING in C are $, @, and `, none of which are in the base character
set [But then, i suspect neither would #, if it weren't used.] # and
$ are a bit "safer" than @ and `, vs national variants, and maybe it was
a coin toss between them. $ is used in system-specific identifiers on
some implementations, but i think the original preprocessor use of
# came before those.
Mar 28 '06 #11
On Tue, 28 Mar 2006 03:35:07 +0000, August Karlstrom wrote:
Keith Thompson wrote:
"Remo" <re*******@gmail.com> writes:
I Have Quation About Macro's plz help

why do we have # symbol before any macro line #define STOP 0 ...

why con't we use the any other symbol like $, @,,

plz answer if any one knows reason.

Because that's how the language syntax is defined. Why would you want
to use a different symbol?


I think Remo's question is quite clear and I'm surprised by all strange
answers. Let me rephrase the question as I interpret it:

Is there any particular reason why the number sign was chosen as a
prefix for preprocessor directives? Tradition?


It is just possible that is is an echo from TRAC -- a general purpose
macro processing language designed by Mooers and Deutch in about 1966
which used # as the main macro marker IIRC. TRAC was intellectually
ingenious and very popular in the early 70s when C and its preprocessor
emerged. Only the original cpp authors can say if they had this in mind.

--
Ben.
Mar 29 '06 #12

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

Similar topics

220
18805
by: Brandon J. Van Every | last post by:
What's better about Ruby than Python? I'm sure there's something. What is it? This is not a troll. I'm language shopping and I want people's answers. I don't know beans about Ruby or have...
2
2132
by: Rex_chaos | last post by:
I have define a MACRO varible as a common variable that be refered by several classes. #ifndef COMMON_VAR #define COMMON_VAR 1 .... #endif
36
18401
by: Peng Jian | last post by:
#define STREQ(a, b) (*(a) == *(b) && strcmp((a), (b)) == 0) I'm a beginner learning C. I can't see what *(a) == *(b) is for. If either a or b is a null pointer, this may cause crash. And if...
4
1452
by: ethan | last post by:
Hi All, I'd like ask some question about macro. If I define a variable set, such as {5, 2, 10} or {1,3}. #define X {5,2,10} 1) Is it possible to write a macro to get the number of items...
53
4020
by: Jeff | last post by:
In the function below, can size ever be 0 (zero)? char *clc_strdup(const char * CLC_RESTRICT s) { size_t size; char *p; clc_assert_not_null(clc_strdup, s); size = strlen(s) + 1;
23
8164
by: Steven T. Hatton | last post by:
This is one of the first obstacles I encountered when getting started with C++. I found that everybody had their own idea of what a string is. There was std::string, QString, xercesc::XMLString,...
10
2180
by: haomiao | last post by:
I want to implement a common list that can cantain any type of data, so I declare the list as (briefly) --------------------------------------- struct list { int data_size; int node_num;...
6
2407
by: Michael B Allen | last post by:
Hi, I have a macro that looks like the following: #define MMSG msgno_loc0(LOC0, LOC1) && msgno_mmsg0 which if used in some code like: MMSG("foo=%s", foo);
3
4404
by: prix prad | last post by:
Hi All, I encountered the above error when I tried to expand a macro as follows: #define EXPAND(array) int M_ ## array The problem occurs when we have 'array' itself as a macro: say...
0
7231
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
7133
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
7504
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
5643
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,...
1
5059
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...
0
4724
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...
0
3198
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1568
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
773
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.