linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* RE: Macro exercise
@ 2006-08-18  9:12 Marius Cosma
  2006-08-18  9:19 ` Marius Cosma
  0 siblings, 1 reply; 2+ messages in thread
From: Marius Cosma @ 2006-08-18  9:12 UTC (permalink / raw)
  To: linux-c-programming

Hello,

I want to use a macro for a structure member, something like:


typedef struct {
  int a;
  int b;
  int c;
} myStruct;

myStruct x;

x.a = 7;
x.b = 8;
x.c = 9;

#undef PARAM
#define PARAM a
printf("x=%d\n", x.##PARAM);

#undef PARAM
#define PARAM b
printf("x=%d\n", x.##PARAM);

#undef PARAM
#define PARAM c
printf("x=%d\n", x.##PARAM);


But I'm having problems in writing it correct (that "x.##PARAM"). Are you
faster than a google search? :)

Thanks



This email is subject to Computaris email terms of use: http://www.computaris.com/email_terms.html

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-08-18  9:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-08-18  9:12 Macro exercise Marius Cosma
2006-08-18  9:19 ` Marius Cosma

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).