From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,fd63afa4dc364b7e X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-03-26 19:08:03 PST Path: supernews.google.com!sn-xit-03!supernews.com!freenix!sunqbc.risq.qc.ca!newsfeed.cwix.com!skin02.micron.net!news03.micron.net.POSTED!not-for-mail Message-ID: <3AC002AA.73118A89@votehere.net> From: Andrew Berg X-Mailer: Mozilla 4.76 [en] (WinNT; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Implementing C/C++ style #include... References: <98m938$2iod0$1@ID-25716.news.dfncis.de> <99alrr$itf$1@nh.pace.co.uk> <99d5dj$fi4$1@nh.pace.co.uk> <99nkte$157$1@nh.pace.co.uk> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Mon, 26 Mar 2001 19:02:02 -0800 NNTP-Posting-Host: 209.203.248.8 X-Trace: news03.micron.net 985662095 209.203.248.8 (Mon, 26 Mar 2001 20:01:35 MST) NNTP-Posting-Date: Mon, 26 Mar 2001 20:01:35 MST Xref: supernews.google.com comp.lang.ada:6097 Date: 2001-03-26T19:02:02-08:00 List-Id: Robert A Duff wrote: > > Pascal Obry writes: > > > I agree with you that in such a case a preprocessor could be usefull. Anothe > > way to handle this is by writing a template and have the right spec generated > > by a script. > > > > function Ada_Size_Of_Input is new > > Interfaces_C_More.Storage_Unit_Size_Of (Input_Type); > > pragma Export (, Ada_Size_Of_Input, > > "ball_ct633_ada_size_of_input", > > "ball_ct633_ada_size_of_input"); > > Your "script" is, in fact, a macro preprocessor. > > Are macros more or less evil than #if things? > I've heard both opinions in this thread. ;-) As a full time C++ programmer, I'm going to have to side with Pascal here. Textual macros are dangerous, but a limited form of dangerous. #if's on the other hand are quite possibly the worst form of evil imaginable, in that it is never really possible to know exactly what is going on. Even in simple cases it is bad, because when maintenance happens they always get worse. I suppose that if you are writing code that will never get looked at they might not be so bad, but I have never had that luxury. Probably the only decent application of #if is '#if 0' as a way to comment out multiple lines of code at once. C's /* */ comments cannot be nested and it gets really tedious to put //'s everywhere, so #if 0 is a useful construct. If you want an example of the kind of hell I am thinking of, go download 'stlport', a reasonably portable, reasonably compliant version of C++'s STL. Look at those header files for a while... -andrew