Best "GCC" compiler for Atari ST?

GFA, ASM, STOS, ...

Moderators: exxos, simonsunnyboy, Mug UK, Zorro 2, Moderator Team

rabindranath72
Captain Atari
Captain Atari
Posts: 244
Joined: Tue Feb 15, 2011 3:59 pm

Re: Best "GCC" compiler for Atari ST?

Postby rabindranath72 » Mon Feb 18, 2013 6:37 pm

simonsunnyboy wrote: // comments for example as well a

According to C programming language, 2nd edition, Kernighan & Ritchie, they are not in the original ANSI C standard. Were they implemented in C99? (they are accepted by gcc, though.)

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 4774
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: Best "GCC" compiler for Atari ST?

Postby simonsunnyboy » Mon Feb 18, 2013 6:55 pm

Yes, that was my last posting regarding additions of the C99 standard.

Basically the main top features of C99 are:
- well defined and thus portable datatypes in stdint.h
- // comments
- variable declaration within nested {} blocks
- structure member initialization in any order and by member name with omitting members:

Code: Select all

struct a_t {
int16_t a;
int16_t b;
int16_t c;
}

struct a_t my_a_var = { .b = 45, // initialize member b
.c = -1000 // initialize member c
};



Except for gcc, no native Atari compiler implements these. stdint.h can be reretrofitted as I did for Pure C and AHCC.
Simon Sunnyboy/Paradize - http://paradize.atari.org/ - STOT: http://www.npoi.de/stot/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

Jabber: simonsunnyboy@atari-jabber.org

User avatar
shoggoth
Nature
Nature
Posts: 848
Joined: Tue Aug 01, 2006 9:21 am
Location: Halmstad, Sweden
Contact:

Re: Best "GCC" compiler for Atari ST?

Postby shoggoth » Mon Feb 18, 2013 7:16 pm

simonsunnyboy wrote:- variable declaration within nested {} blocks


Isn't that just plain vanilla (non-C99) C? (example follows below)

Code: Select all

void burp(void)
{
   int32_t donkey;

   if(1)
   {
      int16_t cheese = 1;

      while(42)
      {
         int8_t banana;

         printf("the brown fox\r\n");
      }
   }
}


C99 however allows us to do inline declarations:

Code: Select all

void burp(void)
{
   for(uint_fast8_t i = 0; i < 100; i++)
   {
      printf("oh noes\r\n");

      bool boink = (i & 0) ? true :  false;
   }
}


Or maybe I misinterpreted you :)
Ain't no space like PeP-space.

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 4774
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: Best "GCC" compiler for Atari ST?

Postby simonsunnyboy » Mon Feb 18, 2013 7:25 pm

gcc may eat this by default. Pure C and AHCC surely don't.

gcc always implemented additions to the official standards.
Simon Sunnyboy/Paradize - http://paradize.atari.org/ - STOT: http://www.npoi.de/stot/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

Jabber: simonsunnyboy@atari-jabber.org

User avatar
shoggoth
Nature
Nature
Posts: 848
Joined: Tue Aug 01, 2006 9:21 am
Location: Halmstad, Sweden
Contact:

Re: Best "GCC" compiler for Atari ST?

Postby shoggoth » Mon Feb 18, 2013 7:58 pm

simonsunnyboy wrote:gcc may eat this by default. Pure C and AHCC surely don't.


And you know this for sure? Because I tried it, and both Pure C and AHCC accepts it. My impression is that this is not C99. I haven't come across a compiler which doesn't support it, hence my last post. Maybe it's C89?

EDIT:
K&R mentions this in section 4.8 ("Block Structure"): "Declarations of variables (including initializations) may follow the left brace that introduces any compound statement, not just the one that begins a function."

There's also an example which looks as follows:

Code: Select all

if (n > 0) {
   int i; /* declare a new i */
   for (i = 0; i < n; i++)
      ...
}
Ain't no space like PeP-space.

joska
Hardware Guru
Hardware Guru
Posts: 3574
Joined: Tue Oct 30, 2007 2:55 pm
Location: Florø, Norway
Contact:

Re: Best "GCC" compiler for Atari ST?

Postby joska » Mon Feb 18, 2013 8:28 pm

simonsunnyboy wrote:gcc may eat this by default. Pure C and AHCC surely don't.


Not correct. Both Pure C and AHCC understands variable declarations within any block. I'm using this all the time myself.

Also, AHCC knows // comments and maybe a few other C99 features.
Jo Even

Firebee - Falcon060 - Milan060 - Falcon040 - MIST - Mega ST - STM - STE - Amiga 600 - Sharp MZ700 - MSX - Amstrad CPC - C64

User avatar
Eero Tamminen
Atari God
Atari God
Posts: 1512
Joined: Sun Jul 31, 2011 1:11 pm

Re: Best "GCC" compiler for Atari ST?

Postby Eero Tamminen » Mon Feb 18, 2013 10:21 pm

joska wrote:
simonsunnyboy wrote:gcc may eat this by default. Pure C and AHCC surely don't.


Not correct. Both Pure C and AHCC understands variable declarations within any block. I'm using this all the time myself.


Yes, they're C89 feature. AFAIK AHCC should have full ANSI-C support...

joska wrote:Also, AHCC knows // comments and maybe a few other C99 features.


One thing that Henk said that he's NOT going to implement from C99 is inlines. :-)

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 4774
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: Best "GCC" compiler for Atari ST?

Postby simonsunnyboy » Tue Feb 19, 2013 3:46 pm

shoggoth wrote:
simonsunnyboy wrote:gcc may eat this by default. Pure C and AHCC surely don't.


And you know this for sure? Because I tried it, and both Pure C and AHCC accepts it. My impression is that this is not C99. I haven't come across a compiler which doesn't support it, hence my last post. Maybe it's C89?

EDIT:
K&R mentions this in section 4.8 ("Block Structure"): "Declarations of variables (including initializations) may follow the left brace that introduces any compound statement, not just the one that begins a function."

There's also an example which looks as follows:

Code: Select all

if (n > 0) {
   int i; /* declare a new i */
   for (i = 0; i < n; i++)
      ...
}


That is quite interesting. I always thought only C99 introduced this feature. I stand corrected. Although i haven't seen C89 or K&R code using this sofar....atleast not code I have actively read.

inlines in AHCC could be supported as a dummy. The parser could allow inline as a keyword but ignore it during code generation. That would at atleast add compatibility to compile stuffs without having to do #define inline for AHCC.

All in all with this offtopic discussion, AHCC is great on the ST!
Simon Sunnyboy/Paradize - http://paradize.atari.org/ - STOT: http://www.npoi.de/stot/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

Jabber: simonsunnyboy@atari-jabber.org

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 4774
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: Best "GCC" compiler for Atari ST?

Postby simonsunnyboy » Tue Feb 19, 2013 5:10 pm

While thinking about it, I think C99 introduced that variables can be declared anywhere in a {} statement, not only at the start of block.
E.q.

Code: Select all

{
  int16_t a = somefunction(b);
  a + = 1500;

  const int16_t c = some_other_function(a);
  int 16_t b = a + c;

 
}
Simon Sunnyboy/Paradize - http://paradize.atari.org/ - STOT: http://www.npoi.de/stot/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

Jabber: simonsunnyboy@atari-jabber.org

User avatar
shoggoth
Nature
Nature
Posts: 848
Joined: Tue Aug 01, 2006 9:21 am
Location: Halmstad, Sweden
Contact:

Re: Best "GCC" compiler for Atari ST?

Postby shoggoth » Tue Feb 19, 2013 7:56 pm

simonsunnyboy wrote:inlines in AHCC could be supported as a dummy. The parser could allow inline as a keyword but ignore it during code generation. That would at atleast add compatibility to compile stuffs without having to do #define inline for AHCC.


This is why many portable projects #define INLINE :)

All in all with this offtopic discussion, AHCC is great on the ST!


It is. Generally I use GCC, but I often compile stuff using AHCC as well. Henk has done a truly great job there.
Ain't no space like PeP-space.

AtariZoll
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2761
Joined: Mon Feb 20, 2012 4:42 pm
Contact:

Re: Best "GCC" compiler for Atari ST?

Postby AtariZoll » Tue Aug 12, 2014 6:55 am

Problem during installation of cross-mint-cygwin , on Windows XP .
I followed instructions at http://vincent.riviere.free.fr/soft/m68k-atari-mint/ , but getting error message when try to install cross-mint :
"Error during installation of binutils-2.24-mint-20131217-bin-cygwin-20131217.tar.bz2" - and con not continue .
Any experiences in resolving this ?
English language is like bad boss on workplace: it expecting from you to strictly follow all, numerous rules, but self bending rules as much likes :mrgreen:

User avatar
Cyprian
Atari God
Atari God
Posts: 1398
Joined: Fri Oct 04, 2002 11:23 am
Location: Warsaw, Poland

Re: Best "GCC" compiler for Atari ST?

Postby Cyprian » Thu Aug 14, 2014 7:02 pm

AtariZoll wrote:Any experiences in resolving this ?

I had no a such problem with Vincent's cross-mint, it worked flawless. But due to lack of my knowledge I had some other issues, and Vincent was really helpful and helped me fix them all.
You can ask him directly - BlankVector.
Jaugar / TT030 / Mega STe / 800 XL / 1040 STe / Falcon030 / 65 XE / 520 STm / SM124 / SC1435
SDrive / PAK68/3 / CosmosEx / SatanDisk / UltraSatan / USB Floppy Drive Emulator / Eiffel / SIO2PC / Crazy Dots / PAM Net
Hatari / Aranym / Steem / Saint
http://260ste.appspot.com/

User avatar
bjjones37
Captain Atari
Captain Atari
Posts: 313
Joined: Thu Jul 29, 2004 1:11 pm
Location: USA

Re: Best "GCC" compiler for Atari ST?

Postby bjjones37 » Mon Sep 22, 2014 12:56 am

Now don't everybody laugh at me at once, but I have been playing with GCC 2.7.2 and GCC 2.8.1 under TOS. I run them from the Gulam shell. I have not attempted anything elaborate yet (as if I would know how!!!) but I am getting them to compile simple programs. At least I confirmed that the compile process is working. So far I am using them under Steem with TOS 2.06. (They do not seem all that slow at 64MHz emulation!) But once I am satisfied, I will move them over to the MegaSTE or TT and try them from there. Once I got a good script set up for the environment variables, the only problem I had was with the libs. On 281 I am using dlibs and on 272 I had to rename one of the libraries (actually copied it to a different name) in order to get it to work. But happily "Hello, World!"
Courtesy is not an option.

User avatar
dml
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 3468
Joined: Sat Jun 30, 2012 9:33 am

Re: Best "GCC" compiler for Atari ST?

Postby dml » Mon Sep 22, 2014 8:22 am

bjjones37 wrote:Now don't everybody laugh at me at once, but I have been playing with GCC 2.7.2 and GCC 2.8.1 under TOS. I run them from the Gulam shell. I have not attempted anything elaborate yet (as if I would know how!!!) but I am getting them to compile simple programs. At least I confirmed that the compile process is working. So far I am using them under Steem with TOS 2.06. (They do not seem all that slow at 64MHz emulation!) But once I am satisfied, I will move them over to the MegaSTE or TT and try them from there. Once I got a good script set up for the environment variables, the only problem I had was with the libs. On 281 I am using dlibs and on 272 I had to rename one of the libraries (actually copied it to a different name) in order to get it to work. But happily "Hello, World!"


GCC 2.7.2 used to work ok for me on a native Atari box. It just had one very annoying habit of silently bombing out in the middle of a make job when it was short of memory - over reliance on virtual memory which isn't there :)

User avatar
farvardin
Captain Atari
Captain Atari
Posts: 343
Joined: Fri Jan 01, 2010 5:50 pm
Location: France
Contact:

Re: Best "GCC" compiler for Atari ST?

Postby farvardin » Sun Jul 23, 2017 10:22 pm

dml wrote:This one...

http://vincent.riviere.free.fr/soft/m68k-atari-mint/

...is both a cross-compiler and native compiler for ST/TT/Falcon etc.

The generated executables will work happily on plain TOS providing you avoid MiNT-specific libraries. I built code for STE without any problems.

http://www.leonik.net/dml/files/pcs512_r2.zip


I've installed it and compiled a quite simple C program (but can't compile on pureC or AHCC) using this command:

Code: Select all

 m68k-atari-mint-gcc fweep.c -o fweep.tos


it doesn't work on plain ST, but it does work with FreeMint.

What can I do to "force" the plain ST mode ?

User avatar
mfro
Atari Super Hero
Atari Super Hero
Posts: 664
Joined: Thu Aug 02, 2012 10:33 am
Location: SW Germany

Re: Best "GCC" compiler for Atari ST?

Postby mfro » Mon Jul 24, 2017 9:29 am

farvardin wrote:

Code: Select all

 m68k-atari-mint-gcc fweep.c -o fweep.tos


it doesn't work on plain ST, but it does work with FreeMint.

What can I do to "force" the plain ST mode ?


gcc compiled code usually works just fine on plain TOS (without any special options). If it doesn't, you probably used something MiNT specific in your program.

User avatar
farvardin
Captain Atari
Captain Atari
Posts: 343
Joined: Fri Jan 01, 2010 5:50 pm
Location: France
Contact:

Re: Best "GCC" compiler for Atari ST?

Postby farvardin » Mon Jul 24, 2017 12:37 pm

There is nothing MiNT specific on it, but maybe some Unix calls. It does compile on Windows though: http://www.ifarchive.org/indexes/if-arc ... fweep.html

User avatar
mfro
Atari Super Hero
Atari Super Hero
Posts: 664
Joined: Thu Aug 02, 2012 10:33 am
Location: SW Germany

Re: Best "GCC" compiler for Atari ST?

Postby mfro » Mon Jul 24, 2017 12:58 pm

farvardin wrote:There is nothing MiNT specific on it, but maybe some Unix calls ...


At a glance, it uses time() for random numbers. IIRC, this is only available through MiNT.

I think it should be rather simple to replace that with calls to Random()

User avatar
farvardin
Captain Atari
Captain Atari
Posts: 343
Joined: Fri Jan 01, 2010 5:50 pm
Location: France
Contact:

Re: Best "GCC" compiler for Atari ST?

Postby farvardin » Mon Jul 24, 2017 9:24 pm

thank you for the information. I've changed time to random. It compiles fine for unix/linux (I can still play games with it), and for atari it still only work with Mint :(


Social Media

     

Return to “Coding”

Who is online

Users browsing this forum: No registered users and 1 guest