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=-0.4 required=5.0 tests=AC_FROM_MANY_DOTS,BAYES_00 autolearn=no 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-21 09:00:08 PST Path: supernews.google.com!sn-xit-03!supernews.com!nntp.cs.ubc.ca!freenix!isdnet!psinet-france!psiuk-f4!psiuk-p4!uknet!psiuk-n!news.pace.co.uk!nh.pace.co.uk!not-for-mail From: "Marin David Condic" Newsgroups: comp.lang.ada Subject: Re: Implementing C/C++ style #include... Date: Wed, 21 Mar 2001 11:45:31 -0500 Organization: Posted on a server owned by Pace Micro Technology plc Message-ID: <99alrr$itf$1@nh.pace.co.uk> References: <98m938$2iod0$1@ID-25716.news.dfncis.de> NNTP-Posting-Host: 136.170.200.133 X-Trace: nh.pace.co.uk 985193147 19375 136.170.200.133 (21 Mar 2001 16:45:47 GMT) X-Complaints-To: newsmaster@pace.co.uk NNTP-Posting-Date: 21 Mar 2001 16:45:47 GMT X-Newsreader: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 Xref: supernews.google.com comp.lang.ada:5970 Date: 2001-03-21T16:45:47+00:00 List-Id: "bhazzard" wrote in message news:OrZxgIisAHA.289@cpmsnbbsa09... > A quick question... > > Is there any way to implement c/c++ style > #ifdef pre-processor statements in Ada. > There is always a way. If you're willing to do the work yourself, you can write a program to parse your Ada code to look for preprocessor directives & output appropriate *new* Ada code before doing the compile. This is a lot of work & I would be inclined to advise against it since most of the C/C++ style preprocessor directives are mostly a way to make more trouble for yourself than you really want. (The conditional compilation, inclusion of files, etc., is the source of *more* pain & horrible code than I care to recall. It was considered and deliberately left out of Ada as a generally agreed upon Bad Thing.) There exists no standard way in Ada to have the sort of pre-processor directives you mention since there are no language defined directives. Some compilers (e.g. GNAT) may give you a means of invoking your own preprocessor prior to compilation, but it is outside the language standard. > Do Ada compilers have a pre-processor ? > They can, but its not part of the standard. Ask your vendor. > I am using Rational on an Sgi and Green Hills on a Sun... the manual set(s) > appear to have no reference to such things... This is what I want to do... > ... > #ifdef TEST_MODE > #include "test_mode.a > #endif > ... > a.make -D TEST_MODE -f *.a > > Also... If you know this is IMPOSSIBLE a brief email to that > effect would be useful.... > "Impossible" is a pretty strong word. Since there are no preprocessor directives in Ada, you would have to roll your own. However, there is a "pragma Debug" that is implemented by a number of compilers & this may get you what you want. Basically, you can embed code within the pragma directive & it is only compiled if you throw some debug switch on the compiler. How it works (and if it exists!) will be implementation dependent. GNAT supports this directive. I believe Aonix does as well. So might other compilers, but you'll have to check. For examples of how to use it, look on my web page under "Ada Programming" and "GNAT Examples" - search that for "pragma debug" and you'll see how to use it in the code. How to toggle it on/off will be up to your compiler. MDC -- Marin David Condic Senior Software Engineer Pace Micro Technology Americas www.pacemicro.com Enabling the digital revolution e-Mail: marin.condic@pacemicro.com Web: http://www.mcondic.com/