Path: utzoo!attcan!uunet!lll-winken!ncis.llnl.gov!ncis!helios.ee.lbl.gov!pasteur!ucbvax!decwrl!purdue!haven!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn ) Newsgroups: comp.lang.c Subject: Re: Preprocessor question Message-ID: <9433@smoke.BRL.MIL> Date: 19 Jan 89 13:26:42 GMT References: <531@ole.UUCP> Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 14 In article <531@ole.UUCP> ray@ole.UUCP (Ray Berry) writes: >#define VAL 3 >#define STR(x) #x > puts("val is " STR(VAL)); > Turbo C produces "3" for STR(VAL); Microsoft produces "VAL" and >leaves it at that. > Which behavior is correct? "Before being substituted, each argument's preprocessing tokens are completely macro replaced as if they formed the rest of the translation unit; no other preprocessing tokens are available." So VAL is first expanded to 3 then the #3 is performed to produce "3".