Path: utzoo!attcan!uunet!ncrlnk!ncrcae!hubcap!gatech!udel!rochester!pt.cs.cmu.edu!unh.cs.cmu.edu!agn From: agn@unh.cs.cmu.edu (Andreas Nowatzyk) Newsgroups: comp.lang.c++ Subject: Re: goodbye cpp ??? (macros vs. inline functions) Message-ID: <3663@pt.cs.cmu.edu> Date: 22 Nov 88 17:32:20 GMT References: <6590072@hplsla.HP.COM> <1757@dataio.Data-IO.COM> <3637@pt.cs.cmu.edu> <1304@cod.NOSC.MIL> Organization: Carnegie-Mellon University, CS/RI Lines: 36 In article <2191@pt.cs.cmu.edu> mball@cod.NOSC.MIL (Michael S. Ball) writes: > ... If > a particular C compiler can't produce good code from comma expressions, > prehaps you should get a better one. Better yet, look at some other > implementations of C++ and see what they do. ... > Sure: get a better compiler is the universal answer. Unfortunately that isn't a viable option in many cases (like in this one). The point is: a macro gives you more controll over what is going on, inline functions don't and there are cases where you need precise control. > Huh! I don't know what you mean by "troublesome nesting", but you can > certainly have inline functions without return values. The decision not to Inline functions cannot use functions that have no return-value (a side-effect of using comma-expressions). Inline functions calling other inline function sometimes inline, somethimes thay don't. Exactly when each case happens is rather arbitrary. >The only way an inline function can tell the line number at a call >is to pass the line number as a parameter to the function, in which >case it will work whether expanded or not. Inline function processing is >done long after preprocessing, which is where the line number is known. Not so fast: the problem is instrument a piece of code whitout changeing it. Whenever that application code is dealing with the simulated environment, the simulator need to know about it. It is possible to do that in C++, but the details are quite messy and involve operator overloading, the use of non-trivial macros and some other stuff. -- Andreas -- -- Andreas Nowatzyk (DC5ZV) Carnegie-Mellon University Arpa-net: agn@unh.cs.cmu.edu Computer Science Department Usenet: ...!seismo!unh.cs.cmu.edu!agn --