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 10:28:18 PST Path: supernews.google.com!sn-xit-03!supernews.com!logbridge.uoregon.edu!hammer.uoregon.edu!skates!not-for-mail From: Stephen Leake Newsgroups: comp.lang.ada Subject: Re: Implementing C/C++ style #include... Date: 26 Mar 2001 13:19:45 -0500 Organization: NASA Goddard Space Flight Center Message-ID: 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> NNTP-Posting-Host: anarres.gsfc.nasa.gov Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: skates.gsfc.nasa.gov 985631651 95 128.183.220.71 (26 Mar 2001 18:34:11 GMT) X-Complaints-To: dscoggin@cne-odin.gsfc.nasa.gov NNTP-Posting-Date: 26 Mar 2001 18:34:11 GMT User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.6 Xref: supernews.google.com comp.lang.ada:6062 Date: 2001-03-26T18:34:11+00:00 List-Id: "Marin David Condic" writes: > I guess I've just seen it done enough different ways that work as well or > better that I don't really see any necessity for a preprocessor to do this > job. Managing different configurations can be handled with package body > substitution, static elimination of code via normal "if" statements, pragma > Debug, available configuration management tools, etc. Not this one: function Ada_Size_Of_Input is new Interfaces_C_More.Storage_Unit_Size_Of (Input_Type); #if GNAT_Compiler pragma Export (C, Ada_Size_Of_Input, "ball_ct633_ada_size_of_input", "ball_ct633_ada_size_of_input"); #elsif ObjectAda_Compiler pragma Export (DLL_STDCALL, Ada_Size_Of_Input, "ball_ct633_ada_size_of_input", "ball_ct633_ada_size_of_input"); #end if; The difference is in the name of the Convention. Preprocessing is, in this case, the best way to handle it. I believe the only alternative is to reproduce the entire package spec, and change this one value. Surely you do not claim that is better from a maintenance point of view? I can only assume you have not personally encountered a situation like this. Until you have, you need to be a little more open :). There are similar examples of needing to support a mix of Ada 83/95, compiler vendors, and targets, where limited, structured, well-designed use of pre-processing is the best way to go. > As a result, I think that trying to include special pre-processor > directives in the source and going through an extra pre-compilation > step (fraught with peril!) is unnecessary and potentially dangerous. "potentially dangerous" yes, just like Unchecked_Conversion and Unchecked_Deallocation. "unecessary" no, just like Unchecked_Conversion and Unchecked_Deallocation! > > (Try looking at some older C code that may have very convoluted > "#include" chains, etc. if you need an example of how dangerous this > can get.) I've never once seen a case where you could accomplish > some goal with a preprocessor that you couldn't accomplish with a > less error prone technique. Have you seen the above case? > So why ask for the trouble? I'm not asking for "trouble", I'm asking for "expressive power". "Trouble" I can handle with coding guidelines and project discipline. Note that the gnat preprocessor does _not_ define "include", only "if". And it does _not_ define macros. -- -- Stephe