473,382 Members | 1,202 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,382 software developers and data experts.

usage of # in the following statement

I have read the Programing language C

6.10.3.2 The # operator
Constraints
1 Each # preprocessing token in the replacement list for a
function-like macro shall be
followed by a parameter as the next preprocessing token in the
replacement list.
Semantics
2 If, in the replacement list, a parameter is immediately preceded by
a # preprocessing
token, both are replaced by a single character string literal
preprocessing token that
contains the spelling of the preprocessing token sequence for the
corresponding
argument. Each occurrence of white space between the argument's
preprocessing tokens
becomes a single space character in the character string literal.
White space before the
first preprocessing token and after the last preprocessing token
composing the argument
is deleted. Otherwise, the original spelling of each preprocessing
token in the argument
is retained in the character string literal, except for special
handling for producing the
spelling of string literals and character constants: a \ character is
inserted before each "
and \ character of a character constant or string literal (including
the delimiting "
characters), except that it is unspecified whether a \ character is
inserted before the \
character beginning a universal character name. If the replacement
that results is not a
valid character string literal, the behavior is undefined. The
character string literal
corresponding to an empty argument is "". The order of evaluation of #
and ## operators
is unspecified.
but I still could not figure out the usage of # in the FAQ. could
anyone help me? thanks in advance

in the FAQ , there is an example i can understand either
#define Str(x) #x
#define Xstr(x) Str(x)
#define OP plus
char *opname = Xstr(OP);
to produce the result opname="plus"

why can not i do it like the below:
#define str(x) #x
#define op plus
char * opname=str(op);
??
Nov 14 '05 #1
3 1300
On 28 Jun 2004 18:20:30 -0700, fj***@163.net (ooze) wrote:
I have read the Programing language C

6.10.3.2 The # operator
[definition snipped]
why can not i do it like the below:
#define str(x) #x
#define op plus
char * opname=str(op);
??


Because of this passage in 6.10.3.1:

After the arguments for the invocation of a function-like macro have
been identified, argument substitution takes place. A parameter in the
replacement list, unless preceded by a # or ## preprocessing token or
followed by a ## preprocessing token (see below), is replaced by the
corresponding argument after all macros contained therein have been
expanded.

--
Eric Amick
Columbia, MD
Nov 14 '05 #2
Eric Amick <er********@comcast.net> wrote in message news:<qo********************************@4ax.com>. ..
On 28 Jun 2004 18:20:30 -0700, fj***@163.net (ooze) wrote:
I have read the Programing language C

6.10.3.2 The # operator


[definition snipped]
why can not i do it like the below:
#define str(x) #x
#define op plus
char * opname=str(op);
??


Because of this passage in 6.10.3.1:

After the arguments for the invocation of a function-like macro have
been identified, argument substitution takes place. A parameter in the
replacement list, unless preceded by a # or ## preprocessing token or
followed by a ## preprocessing token (see below), is replaced by the
corresponding argument after all macros contained therein have been
expanded.


thanks, I see where I just lost
Nov 14 '05 #3
Eric Amick <er********@comcast.net> wrote in message news:<qo********************************@4ax.com>. ..
On 28 Jun 2004 18:20:30 -0700, fj***@163.net (ooze) wrote:
I have read the Programing language C

6.10.3.2 The # operator


[definition snipped]
why can not i do it like the below:
#define str(x) #x
#define op plus
char * opname=str(op);
??


Because of this passage in 6.10.3.1:

After the arguments for the invocation of a function-like macro have
been identified, argument substitution takes place. A parameter in the
replacement list, unless preceded by a # or ## preprocessing token or
followed by a ## preprocessing token (see below), is replaced by the
corresponding argument after all macros contained therein have been
expanded.

thanks, I see where I lost
Nov 14 '05 #4

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

Similar topics

3
by: Vincent | last post by:
Hi I have a problem with pear DB my code : for ($i=0;$i<100000;$i) { $sql = "select id from table where id=x";
5
by: Henri | last post by:
Hi, Ive searching for an reuseable SQL-Statement for follwoing situation: Having e.g. a table tblAdress with some fields like persons full name (as Name), City, Birthdate, Street and so on. ...
2
by: JosR | last post by:
I have a memory problem when running a VB.Net application. The application uses a from frmMain from which another form can be opened: Private Sub OpenTheNewForm() dim frm as New frmSecondform...
11
by: Squid Seven | last post by:
I create a pointer to an item: CardSession *cardSession; Then, later, I use new to create an instance of the item and assign it to that pointer: cardSession = new CardSession(); In...
2
by: SKC | last post by:
Is there a way to find the following in UDB ? 1. How many times an index is used for a duration ? 2. Which SQL/application is using the index? if not, is there a different way to find it ?
8
by: Gaijinco | last post by:
I have always indirectly know how RAM is used when a C++ program is run, but I wanted to be sure I got it right: First the OS copies the whole program to RAM. Every statement of the kind int x;...
7
by: Leonel Gayard | last post by:
Hi all, I had to write a small script, and I did it in python instead of shell-script. My script takes some arguments from the command line, like this. import sys args = sys.argv if args ==...
2
by: mghale | last post by:
Hello, I have to create a trigger to accomplish the following: Before the insert into table A occurs, the trigger must check to see if the combination of two columns (from the insert...
3
by: Ehsan | last post by:
hi coulde any one show me the usage of "yield" keyword specially in this example: """Fibonacci sequences using generators This program is part of "Dive Into Python", a free Python book for...
36
by: mdh | last post by:
May I ask the group this somewhat non-focused question....having now seen "continue" used in some of the solutions I have worked on. ( Ex 7-4 solution by Tondo and Gimpel comes to mind) Is there a...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.