I realise there are a lot of questions related to this issue but I couldn't make head nor tale from the ones I read through.

I'm trying to start learning C for the Amiga and decided to have a try following this tutorial: http://www.pcguru.plus.com/tutorial/amiga_c.html

On reaching this point, I'm already running into noob problems:

#include <proto/intuition.h>
#include <intuition/screens.h>
#include <proto/dos.h>
#include <stdio.h>
int main(void) {

   struct Screen *myScreen;
   if (myScreen = LockPubScreen(NULL)) {
        printf("Public Screen locked.\n");
        Delay(100);
        UnlockPubScreen(NULL, myScreen);
        printf("Public Screen unlocked.\n");
   }
   return 0;
}

I'm using the GCC compiler with the following command from the Shell:

gcc -o LockPubScreen LockPubScreen.c

This returns the following:

Warning: assignment makes pointer from integer without a cast
undefined reference to 'LockPubScreen'
undefined reference to 'Delay'
undefined reference to 'UnlockPubScreen

Apart from 'HelloWorld' this is the first attempt at either C or programming the Amiga so I imagine I missing something obvious.

有帮助吗?

解决方案

You probably need to include one or more of these additional files to get the prototype for the functions you're missing:

#include <intuition/gadgetclass.h>
#include <intuition/IntuitionBase.h>
#include <libraries/gadtools.h>
#include <clib/exec_protos.h>
#include <clib/intuition_protos.h>
#include <clib/gadtools_protos.h>

Then, as NPE suggests, may may run into link errors if your compiler doesn't include the requisite library by default, and if you don't specify it.

其他提示

If you had mentioned that you were trying to compile the program under AmigaOS 4.x, the answer would have been obvious. Library function calls in OS4 must either contain the library interface as well - IIntuition->LockPubScreen(), IDOS->Delay(), etc. - or you must #define __USE_INLINE__ at the beginning of the code.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top