f



pasting "" and "" does not give a valid preprocessing token.

Hi all,
I have a program as below:
-----------
#include<stdio.h>

#define FF(x,b) { \
struct ret *t; \
t->##x = b; \
}

struct ret {
int *a;
};
int main()
{
int y =10,*g;
struct ret *s;
g =&y;
FF(a,g);
printf("val:%x %x\n",s->a,g);
return 0;
}
---------------
When I compile I get the following error:
field.c:17:1: pasting "->" and "a" does not give a valid preprocessing
token

I tried removing the ##,it compiled succesfully but I think doesnt
solve my purpose.

Can anyone please help in getting rid of this error? Am I missing
something here?
gcc version 3.4.6 20060404 (Red Hat 3.4.6-9)

Thanks in adv.
-- 
comp.lang.c.moderated - moderation address: clcm@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line.  Sorry.
0
new
8/28/2009 12:29:14 AM
comp.lang.c.moderated 1019 articles. 0 followers. Post Follow

5 Replies
2272 Views

Similar Articles

[PageSpeed] 8

On 2009-08-28, new <luvraghu@gmail.com> wrote:

> When I compile I get the following error:
> field.c:17:1: pasting "->" and "a" does not give a valid preprocessing
> token

1:why are you pasting ?

2:it is supposed to segfault.

try it like this:

#include<stdio.h>

#define FF(x,b) { \
s->x = b; \
}

struct ret {
int *a;
};
int main()
{
  int y =10,*g;
  struct ret m,*s=&m;
  g =&y; 
  FF(a,g);
  printf("val:%p %p\n",s->a,g);
  return 0;
}
-- 
comp.lang.c.moderated - moderation address: clcm@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line.  Sorry.
0
Jasen
8/31/2009 12:49:51 PM
new wrote:

> I tried removing the ##,it compiled succesfully but I think doesnt
> solve my purpose.

Well, you think incorrectly.  There's absolutely no point using the ## 
operator in that macro, and the compiler rightly informed you of that.
-- 
comp.lang.c.moderated - moderation address: clcm@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line.  Sorry.
0
ISO
8/31/2009 12:52:45 PM
On Fri, 28 Aug 2009 05:59:14 +0530, new <luvraghu@gmail.com> wrote:

> Hi all,
> I have a program as below:
> -----------
> #include<stdio.h>
>
> #define FF(x,b) { \
> struct ret *t; \
> t->##x = b; \
> }
>
> struct ret {
> int *a;
> };
> int main()
> {
> int y =10,*g;
> struct ret *s;
> g =&y;
> FF(a,g);
> printf("val:%x %x\n",s->a,g);
> return 0;
> }
> ---------------
> When I compile I get the following error:
> field.c:17:1: pasting "->" and "a" does not give a valid preprocessing
> token
>
> I tried removing the ##,it compiled succesfully but I think doesnt
> solve my purpose.
>

I think you have not understood the use and purpose of the Token-Pasting  
Operator.

These links might be of help:
http://msdn.microsoft.com/en-us/library/09dwwt6y(VS.80).aspx
http://www.keil.com/support/man/docs/c166/c166_pp_tokenpastingop.htm

Regards,
Jyoti
-- 
comp.lang.c.moderated - moderation address: clcm@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line.  Sorry.
0
Jyoti
8/31/2009 12:53:08 PM
Jasen Betts <jasen@xnet.co.nz> writes:
> 2:it is supposed to segfault.

No, it is not supposed to segfault.  Nothing is ever *supposed* to
segfault.  The standard *allows* the implementation to do whatever it
wants under certain circumstances; this may or may not include
segfaulting, on systems where that word has a meaning.

DES
-- 
Dag-Erling Smørgrav - des@des.no
-- 
comp.lang.c.moderated - moderation address: clcm@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line.  Sorry.
0
utf
9/3/2009 6:45:56 AM
Jasen Betts <jasen@xnet.co.nz> writes:
[...]
> 2:it is supposed to segfault.
[...]

Nothing is ever *supposed* to segfault as far as the C standard is
concerned.  In the situation here (dereferencing an uninitialized
pointer), the behavior is undefined.  A segfault, assuming such a
thing exists on the target system, is just one of an unlimited number
of possibilities -- including quietly behaving as you'd expect.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Nokia
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
-- 
comp.lang.c.moderated - moderation address: clcm@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line.  Sorry.
0
Keith
9/3/2009 6:46:00 AM
Reply:

Similar Artilces:

""""""""""""""""""""""ADD ME""""""""""""""""""""
Hi , Hope you are doing great. Please let me take this opportunity to introduce myself, Iam Karthik working with BhanInfo Inc, a NY based company. We have consultants on our bench on various technologies, my request is to add me to your distribution list and kindly do send me the requirements. i have the below list available 1. Mainframe 2. Java 3.. Financial Analyst 4. Data Architect If there is any vendor ship agreement which has to be signed then I would like to take an opportunity to represent my company and expect your cooperation... We look forward to build a ve...

"""""""""ADD ME""""""""""
Hi , Hope you are doing great. Please let me take this opportunity to introduce myself, Iam Karthik working with BhanInfoi Inc, a NY based company. We have consultants on our bench on various technologies, my request is to add me to your distribution list and kindly do send me the requirements. i have the below list available 1. Mainframe 2. Java 3.. Financial Analyst 4. Data Architect If there is any vendor ship agreement which has to be signed then I would like to take an opportunity to represent my company and expect your cooperation... ...

Urgent Requirement in """""""""""""NEW YORK""""""""""""""""
Hello Partners, Please find the requirement below. Please send the updated resume along with rate and contact no. REQ#1: Title : Java Developer ( Rating Project) Duration : 6 months Rate : open Location : NY strong java, WebLogic 9.2, Web Services, Oracle REQ#2: Title : Java Developer Duration : 4 months Rate : open Location : NY Strong java, SQL REQ#3: Title : VB.Net Consultant Location : NY Duration : 4 months Rate : open Primarily looking at someone who has Excel, VB.net a...

"or" and "and"
Hi, I'm just getting to discover ruby, but I find it very nice programming language. I just still don't understand how the "or" and "and" in ruby... I was playing with ruby and for example made a def to print Stem and Leaf plot (for those who didn't have a statistics course or slept on it, e.g. http://cnx.org/content/m10157/latest/) Here is the Beta version of it: class Array def n ; self.size ; end def stem_and_leaf(st = 1) # if st != (2 or 5 or 10) then ; st = 1 ; end k = Hash.new(0) self.each {|x| k[x.to_f] += 1 } k = k.sort{|a, b| a[0].to_f <=&g...

"my" and "our"
Hi, while testing a program, I erroneously declared the same variable twice within a block, the first time with "my", the second time with "our": { my $fz = 'VTX_Link'; .... ( around 200 lines of code, all in the same block) our $fz = 'VTX_Linkset'; ... } So the initial contents of the $fz declared with "my" is lost, because "our" creates a lexical alias for the global $fz, thus overwriting the previous "my" declaration. It was my error, no question. But I wonder why Perl doesn't mention this - even with "use s...

about "++" and "--"
why this program snippet display "8,7,7,8,-7,-8" the program is: main() { int i=8; printf("%d\n%d\n%d\n%d\n%d\n%d\n",++i,--i,i++,i--,-i++,-i--); } > why this program snippet display "8,7,7,8,-7,-8" Ask your compiler-vendor because this result is IMHO implementation-defined. Check this out: http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.15 http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.16 Regards, Irina Marudina fxc123@gmail.com wrote: > why this program snippet display "8,7,7,8,-7,-8&q...

"/a" is not "/a" ?
Hi everybody, while testing a module today I stumbled on something that I can work around but I don't quite understand. >>> a = "a" >>> b = "a" >>> a == b True >>> a is b True >>> c = "/a" >>> d = "/a" >>> c == d True # all good so far >>> c is d False # eeeeek! Why c and d point to two different objects with an identical string content rather than the same object? Manu Emanuele D'Arrigo wrote: >>>> c = "/a" >>>&...

"out" and "in out"
Hi i found the following explaination: In Ada, "in" parameters are similar to C++ const parameters. They are effectively read-only within the scope of the called subprogram. Ada "in out" parameters have a reliable initial value (that passed in from the calling subprogram) and may be modified within the scope of the called procedure. Ada "out" parameters have no reliable initial value, but are expected to be assigned a value within the called procedure. What does "have no reliable initial value" mean when considering the "out" parameter? By c...

why "::", not "."
Why does the method of modules use a dot, and the constants a double colon? e.g. Math::PI and Math.cos -- Posted via http://www.ruby-forum.com/. On Oct 26, 2010, at 01:48 , Oleg Igor wrote: > Why does the method of modules use a dot, and the constants a double > colon? > e.g. > Math::PI and Math.cos For the same reason why inner-classes/modules use double colon, because = they're constants and that's how you look up via constant namespace. Math::PI and ActiveRecord::Base are the same type of lookup... it is = just that Base is a module and PI is a float....

"If then; if then;" and "If then; if;"
I have a raw data set which is a hierarchical file: H 321 s. main st P Mary E 21 F P william m 23 M P Susan K 3 F H 324 S. Main St I use the folowing code to read the data to creat one observation per detail(P) record including hearder record(H): data test; infile 'C:\Documents and Settings\retain.txt'; retain Address; input type $1. @; if type='H' then input @3 Address $12.; if type='P' then input @3 Name $10. @13 Age 3. @16 Gender $1.; run; but the output is not what I want: 1 321 s. main H 2 321 s. main P Mary E 21 F 3 321 s...

Urgent Requirement for """""""""""""""INFORMATICA DEVELOPER"""""""""""""
Hello Partners, How are you ? Please find the requirements below. Title: Database/ETL Developer Duration: 6 months Location: NY Exp: 7+ Locals preferred Database/ETL requirements (Mandatory) Candidate must have worked with financial instruments, preferably Mutual Funds but, Equities are also ok. PL/SQL - packages, Stored procs, Functions, Aggregate functions, Pipelined Functions Informatica 8.6 - especially complex mappings, complex maplets, complex workflows, transformations Oracle 10g/11g Unix/Linux shell scripting ...

Urgent need """""""""""INFORMATICA DEVELOPER"""""""""""""
Hello Partners, How are you ? Please find the requirements below. Title: Database/ETL Developer Duration: 6 months Location: NY Exp: 7+ Locals preferred Database/ETL requirements (Mandatory) Candidate must have worked with financial instruments, preferably Mutual Funds but, Equities are also ok. PL/SQL - packages, Stored procs, Functions, Aggregate functions, Pipelined Functions Informatica 8.6 - especially complex mappings, complex maplets, complex workflows, transformations Oracle 10g/11g Unix/Linux shell scripting Database/ETL requirements (Optional) ...

["a", "b", "c", "d"] to "a, b, c, d"?
I want to process each element of an array, but the last element should be handled special. Here is an example: def p_ary(ary) str = "" ary.each do |elem| str << elem << ", " end str.chomp!(", ") str end so p_ary(["a", "f", "x", "test"]) produces "a, f, x, test". The code works, but isn't there an easier and more general way for this behaviour? martinus On Tue, 06 Apr 2004 04:23:22 -0700, Martin wrote: > I want to process each element of an array, but the last ele...

"In" "Out" and "Trash"
I just bought a new computer and I re-installed Eudora Light on my new computer. But when I open Eudora, the "In", "Out" and "Trash" links are not on the left side of the screen the way they were on my old computer. How can I get these links back on the left side of the screen? Thank you. On 25 Mar 2007 09:49:22 -0700, "abx" <abfunex@yahoo.com> wrote: >I just bought a new computer and I re-installed Eudora Light on my new >computer. But when I open Eudora, the "In", "Out" and "Trash" links >are ...

Web resources about - pasting "" and "" does not give a valid preprocessing token. - comp.lang.c.moderated

#111: Get Yourself Preprocessing in Just a Few Minutes - CSS-Tricks
There is nothing to be afraid about in this brave new world of preprocessing. Native apps make it so easy that it should be a vital part of any ...

Steganography - Wikipedia, the free encyclopedia
Steganography ( ) is the art and science of writing hidden messages in such a way that no one, apart from the sender and intended recipient, ...

Hixie's Natural Log
Last night I wrote a preprocessor . It will be used by the phoenix guys to preprocess their XUL files so that they can do platform-specific stuff ...

ACL 2010: List of Accepted Papers
ACL会议(Annual Meeting of the Association for Computational Linguistics)是自然语言处理与计算语言学领域最高级别的学术会议,由计算语言学协会主办,每年一届。ACL 2010是第48届年会,将于7月11日~16日在瑞 ...

RightWare Launches Basemark GUI Free on Android Market - We Test It Out
Earlier this year RightWare launched a free version of the popular Basemark ES 2.0 benchmark free on the Android market in the form of B asemark ...

The implication of Jott's discontinued free service for your freemium service
Jott announced that they are discontinuing their free service effective February 2, citing a terrible ad market that is insufficient to support ...

All Streets
New work , now posted. All of the streets in the lower 48 United States: an image of 26 million individual road segments. This began as an example ...

Fundamentals Guide
BlackBerry Skip to Content Global Navigation English Español Français Italiano Deutsch 日本語 Nederlands Português (Brasil) 简体中文 한국어 Bahasa Indonesia ...

Data Mining and Predictive Analytics
Tips, tricks, and comments in data mining and predictive analytics, including data preprocessing, visualization, modeling, and model deployment. ...

Developing Intelligence - The Old Version
Kosslyn's 1990 paper in Cognition describes a cognitive architecture that begins at low-level vision and stretches all the way up into executive ...

Resources last updated: 2/9/2016 4:30:50 AM