Welcome, Guest. Please login or register.

Author Topic: GCC 4.x or Clang for 68k  (Read 6335 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline Bif

  • Full Member
  • ***
  • Join Date: Aug 2009
  • Posts: 124
    • Show all replies
Re: GCC 4.x or Clang for 68k
« on: May 14, 2014, 07:56:36 AM »
Quote from: matthey;764394
I do not have much experience with C++ but I do know it is popular and needed for porting other programs to the Amiga. I know it's less efficient as I have looked at the resulting disassembled executables (I see indirect branches and lots of unused code). Regular C is less complex (simpler syntax), offers most of what I need and can generate more efficient executables. Some programmers need C++ and more GCC compatibility though. A newer version of GCC or Clang would be great but it really needs a persistent effort by a knowledgeable team like the original GeekGadgets team.


C++ is not inherently less efficient than C. With equivalent quality compilers you should be able to produce the same quality of executable. Of course if you use some C++ specific features (e.g. exceptions (usually on by default) + STL library, etc.), you can find your EXEs to be larger due to all the embedded error handling, etc. But you can avoid or disable that kind of stuff. Yes there are some C++ features that come with a bit of overhead (virtuals, etc.), but nobody is forcing you to use that stuff - but when you do, it's usually for a good reason, and you would have to introduce the same indirections in non-standard ways in C code to achieve the same thing. On the other hand C++ provides additional features that can help you code things more quickly and safely (e.g. templates, etc., when used intelligently).

I point that out because at some point I want to start some projects that will run on many platforms, including the Amiga. I don't really want to go back to coding the straight C I used for the first 10 years of my life as I've spent the last 15+ years doing C++ in the game industry (where everyone else freaked out about C++ "inefficiency" when we first started using it, now everyone knows better). It does sound like the Amiga is left out in the cold in regards to modern C++ compilers, which is a bummer. GCC 2.95 was somewhat decent at handling C++ syntax but I do recall there were complaints about code quality for the platforms we used it for, and I would imagine things are similar in Amiga-land, the C++ capable compilers available probably don't generate as efficient code as some of the old well optimized C variants.

Anyway, I'm also curious to see if a more modern GCC or Clang gets supported at some point (for cross compiling, I can't imagine compiling on a 68k Amiga nor do I really want to). If not I'd probably take a quick look at it myself to see what kind of job it is, though I suspect it is a pretty big headache or somebody would have done it by now.