View Single Post
Old 11 September 2021, 23:16   #11
bebbo
bye
 
Join Date: Jun 2016
Location: Some / Where
Posts: 680
Quote:
Originally Posted by sparhawk View Post
I was trying this example code fro the Data Becker Supergrafik book. On the disk there is also the binary which wokrs, but it was compiled with Lattice C. When I try to compile it on bebbos gcc, then the binary crashes.


I assume that I missing some compile or linker option. I have used this gcc for my other project as well, but this is usally not using the OS in most cases and it works.


Seems that only ".c" is allowed as attachment but not ".cpp"



Commandline is this:

Code:
amiga-g++   -I/opt/amiga/utils/include -I/opt/amiga/m68k-amigaos/ndk13-include -I/opt/amiga/m68k-amigaos/ndk-include  -D AMIGA_OS --save-temps -fverbose-asm -Wall -pedantic -mcrt=nix13 -fno-exceptions -fno-rtti -std=c++11 -O2 -mregparm -fno-rtti -O3 -DNDEBUG   -o main.o -c main.cpp
amiga-g++  -D AMIGA_OS --save-temps -fverbose-asm -Wall -pedantic -mcrt=nix13 -fno-exceptions -fno-rtti -std=c++11 -O2 -mregparm -fno-rtti -O3 -DNDEBUG  -Wl,--enable-auto-import main.cpp.o  -o ../bin/CustomScreen.exe -Wl,--out-implib,../bin/libCustomScreen.dll.a -Wl,--major-image-version,0,--minor-image-version,0  -L/opt/amiga/utils/lib -lAmigaUtils -lAmigaGCCUtils



duh - that's a complicated command line...


I'd fix includes

Code:
//#include <utils/dos/dos.h>
also remove duplicate includes... and use exit(0); instead of Exit(0); -- include <stdlib.h> for no warnings.
and then
Code:
m68k-amigaos-gcc -Os main.c -mcrt=nix13 -o sparhawk
and the program is working.


Ah - you want to use -mregparm too: many clib header do not supply the needed __stdargs, also main needs that!
So use the proto includes instead:
Code:
//#include <clib/dos_protos.h>
//#include <exec/types.h>
//#include <exec/memory.h>
//#include <intuition/intuition.h>
//#include <intuition/screens.h>

//#include <clib/exec_protos.h>
//#include <clib/graphics_protos.h>
//#include <clib/intuition_protos.h> 

#include <proto/exec.h>
#include <proto/intuition.h>
#include <proto/graphics.h>

#include <stdio.h>
#include <stdlib.h>

//#include <utils/dos/dos.h>
and use
Code:
m68k-amigaos-gcc -Os main.c -mcrt=nix13 -o sparhawk -mregparm
and it's running fine again - plus it's a tad smaller, not profiting from -mregparm since your program only provides functions without params^^


and be nice to yourself and use volatile (and don't forget __stdargs at main)

Code:
volatile char *LeftMouse = (char *)0xbfe001;

void Color(void);
void Color_Cycle(void);

__stdargs int main(int argc, char *argv[])

there you go

Last edited by bebbo; 26 October 2023 at 13:18.
bebbo is offline  
 
Page generated in 0.04238 seconds with 11 queries