From: REGINA::AUGERI 27-MAR-1985 12:37 To: REX::MINOW Subj: CPP and concatenation of macros When you look at that macro expansion problem, you my also want to look at something else. Reading the manual CPP.MEM, I see that I should be able to concatenate macro definitions using the "#" as a separator. Your example utilizes the value __LINE__ as follows: #define ATLINE foo#__LINE__ Then, invoking the macro ATLINE at some line should evaluate as: foonnn where "nnn" is the line number where the macro is invoked. However, when I do invoke the macro, I get the error: cpp: line nnn, Fatal error: Work buffer overflow %SYSTEM-F-ABORT, abort The message is coming from the function save(c) in module cpp6.c. I have a clue for you about this problem. If I do the following: #define ARG BAR #define YUK FOO#ARG YUK then YUK gets evaluated as FOOBAR. However, if I do the following: #define ARG 123 #define YUK FOO#ARG YUK then I fatal out as described above. It appears that the macro expansion works correctly for a non-numeric argument, but does not work correctly for a numeric argument. Do you have any idea what's happening? Mike Wed 27-Mar-1985 12:36 Maynard time -- Mike Augeri PKO3-1/10C DTN 223-3552 From: REGINA::AUGERI 26-MAR-1985 17:17 To: REX::MINOW Subj: More on CPP Hi Martin, RE: CPP under V4.1 and VAX C compiler T2.0-FT3 I changed the link library I am using to VAXCRTL.OLB and the situation with CPP has improved, but it still gets link errors. The previous error was causing CPP to get an access violation; the current error has no apparent effect. The errors I am getting are: %LINK-W-MULPSC, conflicting attributes for psect ERRNO in module C$$TRANSLATE file SYS$SYSROOT:{SYSDLIB]VAXCRTL.OLB;1 %LINK-W-MULPSC, conflicting attributes for psect ERRNO in module C$PERROR file SYS$SYSROOT:{SYSDLIB]VAXCRTL.OLB;1 %LINK-W-MULPSC, conflicting attributes for psect ERRNO in module C$DATA file SYS$SYSROOT:{SYSDLIB]VAXCRTL.OLB;1 %LINK-W-MULPSC, conflicting attributes for psect ERRNO in module C$SIGVEC file SYS$SYSROOT:{SYSDLIB]VAXCRTL.OLB;1 I tried /define=(errno=SS$_ABORT) as you had suggested when I had this problem trying to compile under V3.7 and our old VAX C compiler and the result is the same. I also have a question regarding how I can use the preprocessor. I am trying to use it to preprocess a file that will subsequently be input to another compiler. In the input file I want to imbed a macro within a unique pair of symbols as follows: #define foo /$ NOOP $/ foo #define bar /$ NOOP $/ bar Running this through CPP yields (skipping the #line command): /$ NOOP $o /$ NOOP $r It looks like CPP is using the last letter of the macro name as the last character of the macro's expansion. Is this a feature, or should I be able to do this? Mike Tue 26-Mar-1985 17:18 Maynard time -- Mike Augeri PKO3-1/10C DTN 223-3552 From: RHEA::DECWRL::"allegra!ihnp4ccataly!arf" "Alan Feuer" 25-MAR-1985 03:10 To: cataly!eagle!allegra!decwrl!dec-rhea!dec-rex!minow Received: from DECWRL by DEC-RHEA with SMTP; Mon, 25 Mar 85 00:07-PST Received: by decwrl.ARPA (4.22.01/4.7.34) id AA09870; Mon, 25 Mar 85 11:07:23 pst Date: Mon, 25 Mar 85 11:07:23 pst Message-Id: <8503251907.AA09870@decwrl.ARPA> Subj: cpp particulars from latest draft standard substitution for formals in a macro body # becomes "" catenation of tokens ## becomes new form of include (this may cause some trouble for vax-C) #include becomes #include where must be of either the form "" or < > From: MINOW 27-MAR-1985 13:08 To: MINOW Subj: comments re ansi Thanks for the response, some questions on implementation: #define foo(bar) printf(# bar) (example for formal-> "actual" What happens if I write foo("xxx") does this generate printf("xxx") or printf(""xxx"") Also, can I substitute into 'x' strings using # Second example: #define concat(a, b) a ## b And I write concat(__LI, NE__) This goes through the concatenator and becomes __LINE__ Does that go through macro expansion to become 123? Also, does ## left-associate or right associate (a ## b ## c)? Also, what is the precedence of # vs. ## On another topic, I was looking at the trigraph stuff ??foo and have decided its a bad idea -- national replacement alphabets are disappearing, and the only proper way to add national replacement alphabets would be to incorporate an ansi escape sequence parser into C's readin routine. You don't want to do that, believe me. Since ISO/Ansi is about to standardize on an 8-bit set that incorporates all the national letters (very similar to the Dec Multinational set), wouldn't it be better to mandate the ISO 8bit set and use a national-letter preprocessor where needed. That way, the ondisk format would always be ISO 8bit, and only printers and editors (or a piped translator) would need changing. Haven't thought through this enough to post it to mod.std.c yet. comments? Martin.