Welcome, Guest. Please login or register.

Author Topic: Compiler  (Read 14008 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline Cymric

  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 1031
    • Show only replies by Cymric
Re: Compiler
« Reply #44 from previous page: June 01, 2003, 08:17:42 PM »
@quiesce:

Karlos already did a great job of answering, and I agree with him: explicitly coding a program so it's fully multi-threaded/tasking is a very tricky job. Let the amount of programs which actually have the sort of threading you want serve as an indication. It's quite often difficult enough as it is to create a single-threaded application without there being bugs in it :-P.
Some people say that cats are sneaky, evil and cruel. True, and they have many other fine qualities as well.
 

Offline quiesceTopic starter

  • Jr. Member
  • **
  • Join Date: Feb 2003
  • Posts: 72
    • Show only replies by quiesce
Re: Compiler
« Reply #45 on: June 02, 2003, 02:41:44 PM »
OK I am finally getting somewhere now. I decided to begin with learning MUI instead of Reaction, as I can't find any documentation on Reaction.

I have successfully made a program which opens some libraries including muimaster, generates some objects, enters a loop and closes them. However there is one 'warning' that is giving me trouble when compiling:
warning: implicit declaration of function 'int DoMethod(...)'

This function is essential for MUI. According to the docs I have, it is defined in amiga.lib. However the location of the prototype isn't mentioned. I would assume that it were in or but including these does not solve the problem. Here is my code in full so someone can point out if I'm doing anything else wrong. :) (and yes I realise I don't do any error checking ;) )

-- main.h

void InitLibs(void);
void FreeLibs(void);
void InitMasterLoop(void);
void InitInterface(void);

extern Object * Application;
extern Object * AppWindow;

-- main.c

#include
#include
#include
#include
#include
#include
#include

#include "main.h"

struct IntuitionBase * IntuitionBase;
struct Library * MUIMasterBase;

Object * Application;
Object * AppWindow;

int main(int argc, char ** argv)
{
    InitLibs(); // Load runtime libraries
    InitInterface(); // Define MUI Objects

    SetAttrs(AppWindow, MUIA_Window_Open, TRUE);

    InitMasterLoop(); // Begin main loop

    SetAttrs(AppWindow, MUIA_Window_Open, FALSE);

    MUI_DisposeObject(Application);
   
    FreeLibs();

    return 0;
}

void InitLibs(void)
{
    MUIMasterBase = OpenLibrary("muimaster.library", 19);
}

void FreeLibs(void);
{
    CloseLibrary(MUIMasterBase);
}

void InitMasterLoop(void)
{
    ULONG sigs = 0;

    while(DoMethod(Application, MUIM_Application_NewInput, &sigs) != MUIV_Application_ReturnID_Quit)
     {
        if(sigs)
        {
            sigs = Wait(sigs | SIGBREAKF_CTRL_C);
            if(sigs & SIGBREAKF_CTRL_C) break;
        }
    }
}

void InitInterface(void)
{
    Application = MUI_NewObject(MUIC_Application,
        MUIA_Application_Title, "MUITest",
        MUIA_Application_Version, "0",
        MUIA_Application_Copyright, "",
        MUIA_Application_Author, ""
        MUIA_Application_Description, "",
        MUIA_Application_Base, ""
        MUIA_Application_Window,
            (AppWindow = MUI_NewObject(MUIC_Window,
                MUIA_Window_Activate, TRUE,
                MUIA_Window_AppWindow, TRUE,
        TAG_DONE)),
    TAG_DONE);
}

// And that's it!
 

Offline quiesceTopic starter

  • Jr. Member
  • **
  • Join Date: Feb 2003
  • Posts: 72
    • Show only replies by quiesce
Re: Compiler
« Reply #46 on: June 02, 2003, 02:45:51 PM »
Sorry, seems the board removed the indenting. :-P
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16882
  • Country: gb
  • Thanked: 6 times
    • Show only replies by Karlos
Re: Compiler
« Reply #47 on: June 02, 2003, 07:37:14 PM »
Heh, I think it's high time this thread was moved to the developer forum ;-)

First and foremost, the prototypes for DoMethod() and DoMethodA() are in clib/alib_protos.h

If you want to indent your source for posting you need to use a non breaking space "& nbsp;" without the space between the & sign and the nbsp; bit (I had to seperate them here otherwise it would be parsed into a real non-breaking space and you wouldn't see it) (thanks to Tickly for telling me that originally ;-) )

A couple of small points that you should consider. How about returning a BOOL from InitLibs() that returns true if the library was opened and false if not? Then you can cleanly exit your program without a crash on systems where v19 of the muimaster.library is not available.

This could be as simple as

BOOL InitLibs()
{
  return (MUIMasterBase = OpenLibrary("muimaster.library", 19)) ? TRUE : FALSE;
}

Incidentally, IIRC the use of void to signify no function arguments is deprecated since ANSI C v2. It certianly is in C++ ;-)
int p; // A
 

Offline cycloid

  • Full Member
  • ***
  • Join Date: Jun 2002
  • Posts: 155
    • Show only replies by cycloid
Re: Compiler
« Reply #48 on: June 02, 2003, 07:55:00 PM »
The issues in the first half of this thread are ones i've come up against lately in trying to get GCC going on an amiga.. can someone PLEASE SET UP A WORKING GCC CONFIGURATION WITH THE 3.9NDK LINK LIBS AND JUST LHA THE LOT AND STICK IT ONLINE? instead of newbies like us who have lots of enthusiasm but are having to download a shed load of #### from aminet and god knows wherelse and have to contemplate bizzare programs to convert libs over etc.

ta
 

Offline Piru

  • \' union select name,pwd--
  • Hero Member
  • *****
  • Join Date: Aug 2002
  • Posts: 6946
    • Show only replies by Piru
    • http://www.iki.fi/sintonen/
Re: Compiler
« Reply #49 on: June 02, 2003, 08:49:16 PM »
@quiesce

Here is a simple ipc example I wrote. Could prove useful.
 

Offline quiesceTopic starter

  • Jr. Member
  • **
  • Join Date: Feb 2003
  • Posts: 72
    • Show only replies by quiesce
Re: Compiler
« Reply #50 on: June 02, 2003, 09:35:56 PM »
@Karlos: Why is void deprecated, and what should I use instead?
 

Offline quiesceTopic starter

  • Jr. Member
  • **
  • Join Date: Feb 2003
  • Posts: 72
    • Show only replies by quiesce
Re: Compiler
« Reply #51 on: June 02, 2003, 09:39:10 PM »
@Piru: Thanks I'll take a look.
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16882
  • Country: gb
  • Thanked: 6 times
    • Show only replies by Karlos
Re: Compiler
« Reply #52 on: June 02, 2003, 09:40:40 PM »
I dunno exactly. Maybe because it's a waste of typing ? :-P

I'm talking about void in argument lists eg

void function(void);

You can just write empty brackets instead:

void function();

Nothing in the brackets means no arguments expected. I think they borowed this from C++ and to give better upwards compatibility with it.
int p; // A
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16882
  • Country: gb
  • Thanked: 6 times
    • Show only replies by Karlos
Re: Compiler
« Reply #53 on: June 02, 2003, 09:42:37 PM »
Actually you might want to check for yourself. I recall reading it in whitepapers on C (esp the ISO 1999 standard) but I may be wrong.

I do know that older C interprets empty brackets as 'no information given' about arguments.

This was deemed unnaceptable in C++ so they opted for the empty brackets means no arguments approach. Which makes more sense anyway ;-)
int p; // A
 

Offline quiesceTopic starter

  • Jr. Member
  • **
  • Join Date: Feb 2003
  • Posts: 72
    • Show only replies by quiesce
Re: Compiler
« Reply #54 on: June 02, 2003, 09:51:20 PM »
OK. Well here's an update on my program. I included the header clib/alib_protos.h> and the program compiled and linked without a single warning or error. However, when I run it, WinUAE exits completely! It never fails to do this. No crash, or anything. It just exits instantly. What the heck could be wrong here?
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16882
  • Country: gb
  • Thanked: 6 times
    • Show only replies by Karlos
Re: Compiler
« Reply #55 on: June 02, 2003, 09:53:06 PM »
Have you tried it on a real miggy? Send it over if you like...
int p; // A
 

Offline quiesceTopic starter

  • Jr. Member
  • **
  • Join Date: Feb 2003
  • Posts: 72
    • Show only replies by quiesce
Re: Compiler
« Reply #56 on: June 02, 2003, 09:55:55 PM »
That's all well and good if it works for you but I can't code if it won't run in WinUAE (I haven't had a real amiga in over a year).
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16882
  • Country: gb
  • Thanked: 6 times
    • Show only replies by Karlos
Re: Compiler
« Reply #57 on: June 02, 2003, 10:03:54 PM »
Well, I meant to see if it bails out here too.

Incidentally, did you add the checks for the library open (see my earlier post) ?

Tying to use a library that isn't open will cause all kinds of mayhem.

-edit-

I seem to recall there were some crashes on the amiga side that the emulator cant cope with so it exits. I've seen it happen before somewhere...
int p; // A
 

Offline quiesceTopic starter

  • Jr. Member
  • **
  • Join Date: Feb 2003
  • Posts: 72
    • Show only replies by quiesce
Re: Compiler
« Reply #58 on: June 02, 2003, 10:05:13 PM »
By commenting out functions, I have managed to find out that it is the call to SetAttrs() that is causing WinUAE to close. Why, I have no idea...
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16882
  • Country: gb
  • Thanked: 6 times
    • Show only replies by Karlos
Re: Compiler
« Reply #59 on: June 02, 2003, 10:09:44 PM »
Looking back at your code post, don't you need to create the object before you go setting its parameters?

-edit-

sorry, I just saw that you did
int p; // A