[omniORB] BUG: macro expansion problem

Alex Hornby alex@anvil.co.uk
Fri, 7 May 1999 12:46:45 +0100 (BST)


Dear all,

Macro expansion is not being done properly, as the ## is left in.
I know macros are nasty, but one of our developers is very attached to 
them.

Here is an example running on omniORB 2.7.1 on solaris 2.6 Sun PRO 4.2.
I have also attached the C++ preprocessor's output for comparison.

Regards,
Alex

-- IDL
#pragma prefix "anvil.co.uk"

#define EV_TAG(tag) \
	struct evtag_ ## tag { \
		tag value; \
		string errortext; \
	}

module example {
    EV_TAG(short);
    EV_TAG(string);
    EV_TAG(long);
    EV_TAG(float);
    EV_TAG(double);
    EV_TAG(Date);
    EV_TAG(DateTime);
    EV_TAG(Currency);
    EV_TAG(Instrument);
    EV_TAG(Agency);
    EV_TAG(Counterparty);
    EV_TAG(Book);
};

-- Output from omniidl2 -E
# 1 "/tmp/idli_0hlVj0.cc" 
#pragma prefix "anvil.co.uk"







module example {
    struct evtag_ ## short { short value; string errortext; };
    struct evtag_ ## string { string value; string errortext; };
    struct evtag_ ## long { long value; string errortext; };
    struct evtag_ ## float { float value; string errortext; };
    struct evtag_ ## double { double value; string errortext; };
    struct evtag_ ## Date { Date value; string errortext; };
    struct evtag_ ## DateTime { DateTime value; string errortext; };
    struct evtag_ ## Currency { Currency value; string errortext; };
    struct evtag_ ## Instrument { Instrument value; string errortext; };
    struct evtag_ ## Agency { Agency value; string errortext; };
    struct evtag_ ## Counterparty { Counterparty value; string errortext; };
    struct evtag_ ## Book { Book value; string errortext; };
};

-- Output from CC -E
#1 "macro_probem.idl"
#pragma prefix "anvil.co.uk" 
#9
module example { 
struct evtag_short { short value ; string errortext ; } ; 
struct evtag_string { string value ; string errortext ; } ; 
struct evtag_long { long value ; string errortext ; } ; 
struct evtag_float { float value ; string errortext ; } ; 
struct evtag_double { double value ; string errortext ; } ; 
struct evtag_Date { Date value ; string errortext ; } ; 
struct evtag_DateTime { DateTime value ; string errortext ; } ; 
struct evtag_Currency { Currency value ; string errortext ; } ; 
struct evtag_Instrument { Instrument value ; string errortext ; } ; 
struct evtag_Agency { Agency value ; string errortext ; } ; 
struct evtag_Counterparty { Counterparty value ; string errortext ; } ; 
struct evtag_Book { Book value ; string errortext ; } ; 
} ; 

-- 
Alex Hornby                        	       Mail:    alex@anvil.co.uk
Anvil Software Limited			       Tel:    +(44)171 749 7900
51-53 Rivington Street			       Direct: +(44)171 749 7925
London EC2A 3SE				       Fax:    +(44)171 749 7916