Compiling C++ for the Saturn?

GO TO ADMIN PANEL > ADD-ONS AND INSTALL VERTIFORO SIDEBAR TO SEE FORUMS AND SIDEBAR

NightCheese

New Member
Joined
Mar 4, 2020
Messages
2
Points
1
Hi all,

First off, thank you for all of your awesome work at keeping the Saturn alive :)

I’m hoping to write some stuff for the Saturn in C++. I was wondering if anyone could point me in the right direction as I’m a little lost!

I have about 5 years of hobbyist level experience in C++ and know nothing about C. I know Sega themselves don’t recommend C++ for the Saturn, but I wanted to try it out anyway :)

I have sh-elf-c++/g++ v9.2.0 as my compiler, but I’m unsure where to start. I know I can use C code and include C headers in C++ with ‘extern “C”’, but it doesn’t seem quite as simple as that? Do I need to do something special with my linker?

I would like to be able to use SGL and SBL. I’m not too interested in custom libraries/SDKs at this point.

Or do you think I’m just wasting my time and should go about learning C instead?

Thanks in advance for the pointers!
 

Ponut

New Member
Joined
Feb 19, 2018
Messages
58
Points
18
Age
25
The basic syntax is virtually identical.
Whether C or C++, you wont have a lot of the basic code libraries because they weren't tested on Saturn.
C will also make s smaller binary, which is pretty important in the long run.
There's also no one else doing this.

So I guess the long and short of it from me is that C or C++ you will be learning "Saturn" and less learning "C" or using "C++".
But hey, maybe someone else knows how you can easily try it.
 

vbt

Staff member
Joined
Dec 16, 2001
Messages
5,272
Points
83
Age
43
C++ works on saturn, you can find a working makefile & linker script on wolf3d for Saturn.
 

NightCheese

New Member
Joined
Mar 4, 2020
Messages
2
Points
1
C++ works on saturn, you can find a working makefile & linker script on wolf3d for Saturn.
Thank you! That's excellent! That's a very good starting point :) I'll see how far I get. Interesting that they are using SDL too. I didn't know that was ported to the Saturn.

C will also make s smaller binary, which is pretty important in the long run.
That is a very valid point that might make C++ unusable. I guess I'll do some experimentation and compare binary sizes.
 

antime

Extra Hard Mid Boss
Joined
Jan 24, 2002
Messages
2,597
Points
48
Website
www.iki.fi
C will also make s smaller binary, which is pretty important in the long run.
That depends entirely on what you're doing. C++ often generates smaller code, but it's also easy to generate dependencies to large libraries (eg. locale support via formatted output). One thing to keep in mind is that the standard containers are still heavily dependant on dynamic memory allocation, so you may want to look at alternatives like EASTL instead. Exceptions require both dynamic memory and can have significant overhead, so should be used sparingly.

Still, C++ is successfully used on 8-bit MCUs with far less memory than a Saturn, so there's no real reason to avoid it either. There's plenty of material available on how best to use it in embedded systems.
 

Ponut

New Member
Joined
Feb 19, 2018
Messages
58
Points
18
Age
25
That's a very good explanation of what I meant by the shorthand of "smaller binary". It's not so accurate, but its a little harder to be dependent on libraries for C than it is C++? Yeah, I don't really know!
 
Top