Path: utzoo!attcan!uunet!snorkelwacker!apple!olivea!orc!inews!cmdnfs!bhoughto From: bhoughto@cmdnfs.intel.com (Blair P. Houghton) Newsgroups: comp.lang.c Subject: Re: ANSI Parsing/Preproc questions Keywords: ANSI X3.159-1989 Message-ID: <430@inews.intel.com> Date: 15 Oct 90 16:07:38 GMT References: <383@goya.dit.upm.es> Sender: news@inews.intel.com Organization: Intel Corp, Chandler, AZ Lines: 35 In article <383@goya.dit.upm.es> esink@turia.dit.upm.es (Eric Wayne Sink) writes >What does ANSI say about comments within tokens ? ie, is the >following legal ? >int variable; >vari/* in the middle */able = 5; No. The comment is whitespace. >Also, does ANSI say anything about the preprocessor contructing tokens >#define macro(X) variX >/* obviously, some operator is needed above [...] */ >macro(5) = 3; /* expands to: vari5 = 3 */ Token-pasting. Use the ## preprocessing operator as follows: #define macro(X) vari ## X /* there's the operator you wanted */ macro(5) = 3; /* becomes vari5 = 3 */ /* HOWEVER */ #define FOO BAR macro(FOO) = 3; /* becomes variFOO = 3, _not_ variBAR = 3 */ >Finally, can anyone send me/point me to examples of C code which >causes problems for parsers/preprocessors ? I've heard something of a >C torture test... Anything I've written in the past ten years should do it :-). >email FAQ to me ?) Just keep on reading this group. The abridged FAQ was posted today, and the full text will be around in about two weeks if the abridged version doesn't tell you enough. --Blair