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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,f34f1a1939dc0c40 X-Google-Attributes: gid103376,public From: Robert A Duff Subject: Re: conditional compilation Date: 2000/08/01 Message-ID: #1/1 X-Deja-AN: 653275203 Sender: bobduff@world.std.com (Robert A Duff) References: <87d7jvp3qq.fsf@chiark.greenend.org.uk> <39857E5F.33C40014@acm.com> <3985FB16.82D140BB@below.for.email.address> <8m6log$r3a$1@nnrp1.deja.com> Organization: The World Public Access UNIX, Brookline, MA Newsgroups: comp.lang.ada Date: 2000-08-01T00:00:00+00:00 List-Id: Ted Dennison writes: > I've often had to figure out someone else's large C program that was > chock full of target-dependent #ifdef's. Its a *nightmare*. Yes, that can be a nightmare. > The Ada approach is supposed to be that you have different source files > for different targets, and use your build tools to choose between > them. That can be a nightmare, too. I've seen cases where there were six different versions of the same file, for six different target environments, each just slightly different. The bulk of the code in those files is the same for all targets. This kind of code duplication leads to trouble: a bug gets fixed in one version, a different bug gets fixed in a different version, and pretty soon the six files have diverged, and you have no idea which differences are truly target dependent, and which are accidental. So if you're going to use that approach, it's important to make the target dependent files as small as possible -- make them contain *only* the stuff that really needs to be target dependent. Unfortunately, you might not know which code is target dependent ahead of time. Tagged types can help here. You can have a default version of each procedure, which works on most targets, and override it only on the one weird target that needs something special. - Bob