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.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,d694b5818a5102b1 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1994-09-17 08:18:54 PST Newsgroups: comp.lang.ada Path: bga.com!news.sprintlink.net!howland.reston.ans.net!europa.eng.gtefsd.com!MathWorks.Com!news2.near.net!noc.near.net!inmet!spock!stt From: stt@spock.camb.inmet.com (Tucker Taft) Subject: Re: Naive question about system dependencies Message-ID: Keywords: Ada C System_Name Sender: news@inmet.camb.inmet.com Organization: Intermetrics, Inc. References: Date: Fri, 16 Sep 1994 17:28:49 GMT Date: 1994-09-16T17:28:49+00:00 List-Id: In article , Howard Holm wrote: >I have some experience using Ada in a classroom setting, but unfortunately >little experience using it in any real-world settings. I was considering how >I would go about writing a program that was intended to be used in several >different operating system environments (e.g. OS/2 and UNIX). If I were using >C, I would either use compiler generated macros, if they existed, or create >some macros in the makefile that could be used to determine which system was >the target (i.e. #ifdef OS2). The most likely equivalent seemed to me to be >the System_Name constant in the System package. However, when I checked, the >Gnat compiler simply uses "GNAT" for that definition. So, my question is how >do you go about accounting for differences in GUI's and the like? Do you have >a build directory that you copy implementation specific low-level packages >into and out of for each build, or do you define a search path and have a >collection of implementation specific directories and an independent >directory? Or, did I overlook some other language featue to address this >question? Some people use the C preprocessor (or equivalent) with Ada source code. However, in our environment we have found it is more maintainable to avoid using the preprocessor approach, and define interfaces to isolate target/host independent code from target/host dependent code, and then have separate bodies to implement the interface for each target/host. Although this might seem like more work, in the long run it vastly simplifies the process of moving to a new target or host, and keeps the code much more readable than when ifdef's and associated target dependences are littered around the code. >Howard Holm >hholm@clark.net -Tucker Taft stt@inmet.com