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.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,4873305131bf4d94 X-Google-Attributes: gid103376,public X-Google-Thread: 1014db,4873305131bf4d94 X-Google-Attributes: gid1014db,public From: Alan E & Carmel J Brain Subject: Re: Porting (was ADA and Pascal etc) Date: 1997/10/31 Message-ID: <345AB871.413A@dynamite.com.au>#1/1 X-Deja-AN: 286941108 References: <34557f2b.1934172@news.mindspring.com> <34566fe9.447229@news.mindspring.com> <345673af.1413708@news.mindspring.com> <3456b9f3.0@news.eznet.net> <3456e71b.3833189@news.mindspring.com> <3459AC95.1D75@dynamite.com.au> <63bhta$g2e@bgtnsc03.worldnet.att.net> Organization: @home Reply-To: aebrain@dynamite.com.au Newsgroups: comp.lang.ada,comp.lang.c Date: 1997-10-31T00:00:00+00:00 List-Id: Craig Franck wrote: > > Jon S Anthony wrote: > >Alan E & Carmel J Brain writes: > > > >> C and C++ compilers differ by so much that porting is often a Nightmare. > >> Before I get flamed, I'd like to talk to people who've actually ported > >> code cross-platform. > > > >That's about right. Porting anything of substance written in C even > >between compilers on the _same_ platform is depressing. FOE here... > > Sounds like you may have been a victim of the run of your patients. > Well written C code is very portable. I've seen compiler upgrades > break code, but only because it was trash to begin with. May I respectfully offer a counterexample? Code Warrior accepts void Main() { for (int i ; i < SomeValue ; i++ ) { // Do something } for (int i ; i < SomeOtherValue ; i++ ) { // Do something else } } As by one reading of the (yet-to-be-standardised C++ spec) the scope of each i is limited to reside within the parens {} of each loop. Yet MVC++ 5 barfs: as the scope of i is deemed to be within the main program, so the two int i declarations clash. I do not consider the above code to be "trash". If you do, please elucidate as to why (heck, I could be wrong, have been before, will be again) > >> In my own, albeit limited experience, the problems I've had with any > >> C or C++ port are greater than all the problems I've had with Ada > >> crossplatform put together! > > > >That rings true as well. Typically porting Ada code between platforms > >or compilers amounts to a recompilation. > > Something like a Windows to Mac port? How platform specific was the > code? A recompilation port would be the ideal we all chase after. If > you have such great splatfrom tools, you should feel lucky. The above code isn't exactly platform specific, is it? The problems with porting C++ aren't in the areas of platform-specificity, which careful coding in any language isolates and contains. No, it's in things like the STC library, where CodeWarrior 9 accepts instantiation of a vector of objects for which the '<' operation isn't defined, providing you never try sorting, whereas MVC++ 5 doesn't. But IIRC MVC++ 4 does. To recapitulate: often (not always, but more times than not) a port of Ada crossplatform requires only recompilation. Port from compiler to compiler ditto, but more so. I have yet to see such a thing when porting C++. I've seen it once in C, because we had a pre-compiler that heavily massaged the source code first ( a diff showed about 5% difference) Try having a go at the lovelace Ada tutorial at http://www.adahome.com . You may hate it, of course. But it also may give you insights into how to code C and C++ better. IMHO it's worth a look for any C programmer anyway, just as all Ada programmers should be exposed to C { if only to beef up their resistance :) } -- aebrain@dynamite.com.au <> <> How doth the little Crocodile | Alan & Carmel Brain| xxxxx Improve his shining tail? | Canberra Australia | xxxxxHxHxxxxxx _MMMMMMMMM_MMMMMMMMM abrain@cs.adfa.oz.au o OO*O^^^^O*OO o oo oo oo oo By pulling MAERKLIN Wagons, in 1/220 Scale