English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language

 
 
Thread Tools
Old 14 July 2021, 18:53   #1
JJ__
Registered User
 
Join Date: Jan 2021
Location: UK
Posts: 53
Amiga C++ vs PC version

Hi All,

After typing in a relatively simple C++ program I found on the web and compiling it in Storm C version 3, I noticed that there are multiple compilation errors being flagged. The first line I was able to fix by looking at another program written in C++ on Storm C, but is there anywhere which has a list of Amiga specific versions of commands etc that map to more modern C++ usage?

The PC version program is shown here ... https://www.programiz.com/cpp-progra...raphical-order

The first line I was able to amend to "#include <iostream.h>" and it passed the compile test, but the second line "using namespace std;" Storm C didn't like and I've no idea how to fix it ... and then there are around 23 errors in total evidently for this program.

Cheers in advance for any help on this!
JJ__ is offline  
Old 14 July 2021, 19:15   #2
nogginthenog
Amigan
 
Join Date: Feb 2012
Location: London
Posts: 1,309
All of the native C++ compilers for the Amiga are pretty old.
If you want something more modern you will need to cross-compile.

I tried the first example on that page and it compiles and runs with Bebbo's GCC port.
https://github.com/bebbo/amiga-gcc

Code:
m68k-amigaos-g++ -noixemul -O2 test.cpp -s -o test
It's an 800Kb executable!
nogginthenog is offline  
Old 14 July 2021, 19:41   #3
JJ__
Registered User
 
Join Date: Jan 2021
Location: UK
Posts: 53
Quote:
Originally Posted by nogginthenog View Post
All of the native C++ compilers for the Amiga are pretty old.
If you want something more modern you will need to cross-compile.

I tried the first example on that page and it compiles and runs with Bebbo's GCC port.
https://github.com/bebbo/amiga-gcc

Code:
m68k-amigaos-g++ -noixemul -O2 test.cpp -s -o test
It's an 800Kb executable!
Thanks for the tip for the cross-compiler, but I wanted to actually program on my A1200 really instead of using a cross-compiler. I know it's old fashioned, but from the looks of it I'm going to struggle to develop for the Amiga natively sadly.
JJ__ is offline  
Old 14 July 2021, 21:36   #4
hitchhikr
Registered User
 
Join Date: Jun 2008
Location: somewhere else
Posts: 511
Code:
#include <iostream>
//using namespace std;

int main()
{
    std::string str[10], temp;

    std::cout << "Enter 10 words: " << std::endl;
    for(int i = 0; i < 10; ++i)
    {
      getline(std::cin, str[i]);
    }

    // Use Bubble Sort to arrange words
    for (int i = 0; i < 9; ++i) {
        for (int j = 0; j < 9 - i; ++j) {
            if (str[j] > str[j + 1]) {
                temp = str[j];
                str[j] = str[j + 1];
                str[j + 1] = temp;
            }
        }
    }

    std::cout << "In lexicographical order: " << std::endl;

    for(int i = 0; i < 10; ++i)
    {
       std::cout << str[i] << std::endl;
    }
    return 0;
}
"using namespace std;" is just a convenient way to not to write the class name each time it is used in the source.
I'm not sure that getline is available in storm C.

The 800k are taken by the c++ standard library.
hitchhikr is offline  
Old 08 November 2022, 15:59   #5
bebbo
bye
 
Join Date: Jun 2016
Location: Some / Where
Posts: 680
you can save some bytes by specifying
Code:
  -Wl,-gc-sections
bebbo is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Why Myth's C64 version is better than Amiga version? amuleth Retrogaming General Discussion 45 26 January 2018 12:22
Does anyone have a working version of SWOS with JST loader 2mb version? earok support.Games 1 20 October 2015 21:15
Version 1.50 does not recognise ROMS - Vista 32 sp1 4gig 8800 . Version 1.5beta21 ok Southie support.WinUAE 3 02 July 2008 15:49
Old version number? [GameBase version vs. GBA version + misc. questions] wanderer project.MAGE 5 23 August 2007 00:51
I need an official version of Cannon Fodder! The cracked version can't save! Sky_Shadow support.Games 6 23 August 2005 18:39

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 20:04.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.07340 seconds with 13 queries