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,99f33f51845a7793 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-11-20 08:29:00 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!lon1-news.nildram.net!newsfeed.wirehub.nl!bnewspeer00.bru.ops.eu.uu.net!bnewsifeed00.bru.ops.eu.uu.net!bnewspost00.bru.ops.eu.uu.net!emea.uu.net!not-for-mail From: "David Crocker" Newsgroups: comp.lang.ada References: <3be27344$0$227$ed9e5944@reading.news.pipex.net> <3BE42900.7590E899@adaworks.com> <3be65f4c$0$237$ed9e5944@reading.news.pipex.net> <3BF6E4DF.FA47ACDB@adaworks.com> <3BF93F0F.D5E4D0B7@Raytheon.com> <3BFA6BDC.26E7557E@Raytheon.com> Subject: Re: 'withing' problem [code generation] Date: Tue, 20 Nov 2001 16:34:04 -0000 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2919.6600 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600 Message-ID: <3bfa84ca$0$8514$ed9e5944@reading.news.pipex.net> NNTP-Posting-Host: andrew.imsltd.com X-Trace: 1006273738 reading.news.pipex.net 8514 194.202.27.87 X-Complaints-To: abuse@uk.uu.net Xref: archiver1.google.com comp.lang.ada:16726 Date: 2001-11-20T16:34:04+00:00 List-Id: It's not hard to come up with a system that makes the order of C++ include files unimportant. Our product currently generates C++ (we would like to generate Ada, which is why I started this thread) so we needed just such a scheme. Our solution uses 2 header files for each main file. The phase 1 header file just contains forward declarations for all the classes declared, then the phase 2 header file contains the class declarations proper. Each main file first includes all relevant phase 1 header files (in alphabetical order) and then all relevant phase 2 header files (also in alphabetical order). The phase 2 header files include other phase 2 header files only where there is a strong dependency (i.e. class inheritance). Strong dependencies are not circular. Of course, we also use the usual header guards to ensure each file only gets included once. The nicest solution is the one used by Java (and by our own product) - no restriction at all on forward referencing classes/types, or on packages referring to each other (except for absurd cases like 2 classes inheriting from each other). This is the way all programming languages should go, IMO. Forward-declarations should be considered obsolete - they only exist to make life easier for the compiler writer, and compiler technology has come a long way now. -- David Crocker, Escher Technologies Ltd. www.eschertech.com "Mark Johnson" wrote in message news:3BFA6BDC.26E7557E@Raytheon.com... (snip) > I thought about this a little last night and you have the circular dependency problem > in C if you are not careful. You get an infinite loop in the C preprocessor if > doctor.h includes patient.h and vice versa. Almost everybody codes their header files > to have some #ifundef that encloses the body of the header file. That way, each > header is expanded only once. Even with that, you could have a subtle bug due to the > different order of expansion - doctor before patient or patient before doctor. Icky, > nasty problems to find and fix..