camiga

Warning: assignment makes pointer from integer without a cast undefined


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.


Solution

  • 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.