![]() |
![]() |
![]() |
#1 |
Registered User
![]() Join Date: Apr 2016
Location: Perth, Australia
Posts: 256
|
My simple Hello World gurus on exit
Hello all
I am well experienced in C but not on Amiga. I am using the VS Code extension for a convenient dev environment. I am merely opening a window and waiting for the user to close it. When it exits I get a software failure. Any ideas why? Thanks so much! <3 Code:
#include "support/gcc8_c_support.h" #include <proto/exec.h> #include <proto/dos.h> #include <proto/graphics.h> #include <proto/intuition.h> #include <intuition/intuition.h> struct ExecBase *SysBase; struct DosLibrary *DOSBase; struct IntuitionBase *IntuitionBase; int main() { SysBase = *((struct ExecBase**)4UL); struct NewWindow NewWindow; struct Window *Window; IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library", 0); if (IntuitionBase == NULL) Exit(RETURN_ERROR); NewWindow.LeftEdge = 20; NewWindow.TopEdge = 20; NewWindow.Width = 300; NewWindow.Height = 100; NewWindow.DetailPen = 0; NewWindow.BlockPen = 1; NewWindow.Title = "DF0"; NewWindow.Flags = SMART_REFRESH | ACTIVATE | WINDOWCLOSE | WINDOWDRAG; NewWindow.IDCMPFlags = CLOSEWINDOW; NewWindow.Type = WBENCHSCREEN; NewWindow.FirstGadget = NULL; NewWindow.CheckMark = NULL; NewWindow.Screen = NULL; NewWindow.BitMap = NULL; NewWindow.MinWidth = 0; NewWindow.MinHeight = 0; NewWindow.MaxWidth = 0; NewWindow.MaxHeight = 0; if ((Window = (structWindow *)OpenWindow(&NewWindow)) == NULL) Exit(RETURN_ERROR); Wait(1 << Window->UserPort->mp_SigBit); CloseWindow(Window); CloseLibrary(IntuitionBase); Exit(RETURN_OK); } |
![]() |
![]() |
#2 |
Zone Friend
Join Date: May 2006
Location: France
Posts: 1,285
|
it works fine without the last Exit(RETURN_OK); after closing intuitionbase, there's a missing space in that line but I guess it is a typo.
if ((Window = (structWindow *)OpenWindow(&NewWindow)) == NULL) Exit(RETURN_ERROR); |
![]() |
![]() |
#3 |
This cat is no more
Join Date: Dec 2004
Location: FRANCE
Age: 49
Posts: 4,922
|
Which compiler are you using? if you're using gcc you should set -noixemul option
|
![]() |
![]() |
#4 |
Registered User
![]() Join Date: Dec 2010
Location: Athens/Greece
Age: 49
Posts: 569
|
I think you are not supposed to call Exit() but exit()
|
![]() |
![]() |
#5 | |
Registered User
![]() Join Date: Apr 2016
Location: Perth, Australia
Posts: 256
|
Quote:
The custom gcc that comes with the Visual Studio Code extension. Using that option in the makefile just gives me: m68k-amiga-elf-gcc: error: unrecognized command-line option '-noixemul' I have to call Exit because exit is undefined. Also Exit is used in the example code |
|
![]() |
![]() |
#6 | |
Registered User
![]() Join Date: Apr 2016
Location: Perth, Australia
Posts: 256
|
Quote:
Yes that was an error when copying and pasting the code into this forum post. The space isnt really there |
|
![]() |
![]() |
#7 | |
Registered User
![]() Join Date: Dec 2010
Location: Athens/Greece
Age: 49
Posts: 569
|
Quote:
If the C compiler enviroment doesn't provide exit() then it is broken, as exit() is kind of fundamental. Further more, when -- and only when -- you are inside main (as your sample is), you can replace exit(n); with return n; |
|
![]() |
![]() |
#8 |
Registered User
![]() Join Date: Jul 2018
Location: France
Posts: 559
|
Exit is part of dos.library, which you haven't opened. Adding
Code:
DOSBase = (struct DOSBase *) OpenLibrary("dos.library", 0); |
![]() |
![]() |
#9 | |
Registered User
![]() Join Date: Apr 2016
Location: Perth, Australia
Posts: 256
|
Quote:
Thanks, return 0 fixes the error. I normally use return n but I was following the example code that uses Exit(n) even in main(). |
|
![]() |
![]() |
#10 |
PPC Hacker
![]() Join Date: Mar 2012
Location: Leiden / The Netherlands
Posts: 1,344
|
Are you even linking to a c lib? Also where is the header file for exit()? stdlib.h
|
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Any Octamed/MIDI gurus? | marm | support.Apps | 25 | 25 September 2019 14:35 |
One for the Electronics Gurus... Please | Charlie | Hardware pics | 3 | 04 July 2009 04:01 |
Getting a lot of gurus on A500! | memothejanitor | support.Apps | 7 | 22 June 2007 22:30 |
My WinUAE HD GURUs at startup | jjsmith22 | support.WinUAE | 7 | 09 April 2005 03:19 |
Scandoubler gurus needed. | Desverger | support.Hardware | 7 | 05 August 2004 17:57 |
|
|