10 September 2021, 16:57 | #1 |
Registered User
Join Date: Sep 2019
Location: Essen/Germany
Age: 55
Posts: 463
|
Opening Custom screen crashes
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 Last edited by sparhawk; 10 September 2021 at 17:21. |
10 September 2021, 18:57 | #2 |
Registered User
Join Date: Feb 2017
Location: Denmark
Posts: 1,098
|
Remove (or comment out) the line that includes <utils/dos/dos.h>, and try to compile with just
Code:
amiga-g++ main.cpp -o main.exe -mcrt=nix13 If that also works for you, then try adding back in some of your other compiler/linker flags |
10 September 2021, 20:50 | #3 |
Registered User
Join Date: Sep 2019
Location: Essen/Germany
Age: 55
Posts: 463
|
Thanks for trying it, so at least I know now that the source is working, as I assumed. Have to hunt it down where it goes wrong now...
|
10 September 2021, 21:26 | #4 |
This cat is no more
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,160
|
do you have a 68000? because it doesn't work on 68000 (startup code has word read at odd addresses)
|
10 September 2021, 21:59 | #5 | |
Registered User
Join Date: Feb 2017
Location: Denmark
Posts: 1,098
|
Quote:
Are you compiling with all of OPs compiler/linker options? Doing only what I wrote in my reply I get the attached binary, which works fine w/ UAE A500 quickstart. Adding " -fverbose-asm -Wall -pedantic -mcrt=nix13 -fno-exceptions -fno-rtti -std=c++11 -fno-rtti -O3 -DNDEBUG -s --save-temps" also seems fine, "-mregparm" however does not. |
|
10 September 2021, 23:23 | #6 | |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
This is a C source. I don't see any C++ in it.
Quote:
Really the only problem is the <utils/dos/dos.h>, which paraj already mentioned. It doesn't exist, but isn't required either. |
|
11 September 2021, 15:46 | #7 | |
Registered User
Join Date: Sep 2019
Location: Essen/Germany
Age: 55
Posts: 463
|
Quote:
Yeah, it looks like regparm is the problem, though I fail to see why. When calling OS routines, they use regparams anyway. |
|
11 September 2021, 15:48 | #8 |
Registered User
Join Date: Sep 2019
Location: Essen/Germany
Age: 55
Posts: 463
|
Yeah, because it didn't work with my original project and so I tested some older C code to see if there is a problem with my code or something else. Anyway, it shouldn't matter if I use g++ or gcc because both should work with this simple code, right? |
11 September 2021, 18:01 | #9 | |
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 47
Posts: 3,751
|
Quote:
Edit: Took a quick look at the code, and it's definitely not simple enough to be guaranteed to not make a difference. |
|
11 September 2021, 20:07 | #10 | |
Registered User
Join Date: Sep 2019
Location: Essen/Germany
Age: 55
Posts: 463
|
Quote:
That's strange, because most of my code is ASM and some stuff I do with g++, without OS, and I never had any issues. But that 'regparm' can explain it, as I had problems with that before when forgot to keep that in mind. |
|
11 September 2021, 23:16 | #11 | |
bye
Join Date: Jun 2016
Location: Some / Where
Posts: 680
|
Quote:
duh - that's a complicated command line... I'd fix includes Code:
//#include <utils/dos/dos.h> and then Code:
m68k-amigaos-gcc -Os main.c -mcrt=nix13 -o sparhawk 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> Code:
m68k-amigaos-gcc -Os main.c -mcrt=nix13 -o sparhawk -mregparm 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. |
|
12 September 2021, 14:25 | #12 |
Registered User
Join Date: Sep 2019
Location: Essen/Germany
Age: 55
Posts: 463
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Does anyone know why CygnusEd 5.6 crashes | source | support.Apps | 4 | 04 November 2017 03:38 |
3.5.0 crashes on me | NLS | support.WinUAE | 7 | 22 June 2017 15:50 |
Asm-One crashes in 3.1.0 | b00mer | support.WinUAE | 4 | 10 November 2015 09:11 |
Two WinUAE crashes | thor | support.WinUAE | 5 | 06 November 2007 20:15 |
3D code and/or internet code for Blitz Basic 2.1 | EdzUp | Retrogaming General Discussion | 0 | 10 February 2002 11:40 |
|
|