18 December 2017, 20:59 | #1 |
Registered User
Join Date: Dec 2017
Location: London
Posts: 51
|
vbcc warning assignment of different pointers
hopefully this is a basic question but google search for last few hours isn't yielding anything meaningful.
I'm new to C as I haven't touched it for over 20 years and even then it wasn't hard core. But I am a programmer. I keep getting a warning from vbcc compiler and I'm scratching my head. Code:
/Users/jaglally/amigaDev/vbcc/bin/vc +kick13 -c99 -I/Users/jaglally/amigaDev/NDK_3.9/Include/include_h IntuitionWindow.c -lamiga -lauto -o intuitionWindow2 > windowPtr = OpenMyNewWindow(IntuitionBase); warning 85 in line 62 of "IntuitionWindow.c": assignment of different pointers Code:
// // IntuitiionWindow2.c // #include <exec/types.h> #include <intuition/intuition.h> #include <clib/exec_protos.h> #include <clib/intuition_protos.h> #include <stdlib.h> #include <stdio.h> #include <proto/dos.h> #define INTUITION_REV 0 struct Window * OpenMyNewWindow(struct IntuitionBase *IntuitionBase) { printf("OpenMyNewWindow. IntuitionBase passed just for the hell of it %p \n",(void *)IntuitionBase); // structure of type NewWindow also called NewWindow. struct NewWindow newWindowDef; // pointer to structure of type Window. struct Window *windowPtr = NULL; newWindowDef.LeftEdge = 20; newWindowDef.TopEdge = 20; newWindowDef.Width = 300; newWindowDef.Height = 100; newWindowDef.DetailPen = 0; newWindowDef.BlockPen = 1; newWindowDef.Title = "A Simple Window 5"; newWindowDef.Flags = WINDOWCLOSE | SMART_REFRESH | ACTIVATE | WINDOWSIZING | WINDOWDRAG | WINDOWDEPTH | NOCAREREFRESH; newWindowDef.IDCMPFlags = CLOSEWINDOW; newWindowDef.Type = WBENCHSCREEN; newWindowDef.FirstGadget = NULL; newWindowDef.CheckMark = NULL; newWindowDef.Screen = NULL; newWindowDef.BitMap = NULL; newWindowDef.MinWidth = 0; newWindowDef.MinHeight = 0; newWindowDef.MaxWidth = 600; newWindowDef.MaxHeight = 400; // call OpenWindow with address of structure definition. returns a pointer. windowPtr = OpenWindow(&newWindowDef); return windowPtr; } int main(int argc, char **argv) { // structure of type library pointer call IntuitionBase struct IntuitionBase *IntuitionBase = NULL; struct Window *windowPtr = NULL; // function declared to return a general library pointer. opening Intuition returns // IntuitionBase which has extra data IntuitionBase = (struct IntuitionBase *) OpenLibrary("intuition.library", INTUITION_REV); if (IntuitionBase == NULL) exit(FALSE); printf("Intuition library opened. base address %p \n",(void *)IntuitionBase); windowPtr = OpenMyNewWindow(IntuitionBase); if ( windowPtr == NULL) { printf("holy crap. OpenMyNewWindow did not work\n"); exit(FALSE); } Wait(1 << windowPtr->UserPort->mp_SigBit); CloseWindow(windowPtr); CloseLibrary((struct Library *) IntuitionBase); return 0; } |
18 December 2017, 21:45 | #2 |
Registered User
Join Date: Dec 2017
Location: London
Posts: 51
|
I can't believe I sort of figured it out within 40 minutes of posting after spending hours. I needed to tidy up my includes to
Code:
#include <stdio.h> #include <stdlib.h> #include <exec/types.h> #include <intuition/intuition.h> //#include <clib/exec_protos.h> //#include <clib/intuition_protos.h> #include <proto/exec.h> #include <proto/intuition.h> #include <proto/dos.h> |
18 December 2017, 23:58 | #3 | |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
Quote:
The problem here was that "struct IntuitionBase" was completely unknown. And, admitted, the error message was misleading. You can reproduce that with a simple test (here "struct xyz" is unknown): Code:
void f(struct xyz *x) { x = 0; } int main() { struct xyz *tst = 0; f(tst); return 0; } Code:
frank@tethys vc +aos68k tst.c > f(tst); warning 85 in line 10 of "tst.c": assignment of different pointers |
|
19 December 2017, 20:16 | #5 |
Registered User
Join Date: Dec 2017
Location: London
Posts: 51
|
Thanks both of you. It was a big help in understanding. I sort of managed to follow the include logic and see what you said. The linked post also helped.
I also see that vbcc also has clib with protos as part of targets. E.g. m68k-kick13. Would you know the reason why someone would choose these over the NDK ones or when to choose one over the other? |
21 December 2017, 14:42 | #6 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
Last time I checked all the official AmigaOS 3.x SDKs did not include a proto directory, only clib. proto is compiler specific and should be provided with the compiler (or the compiler's target files).
"clib" only contains simple C prototypes, and requires you to link your code with stub functions from amiga.lib, which do the actual OS-calls from these stubs. All modern Amiga compilers also support direct OS calls, elimintating the overhead of calling such a stub function. But that's done with compiler-specific extensions, which are not part of the official C standard (like assembler inlines, or pragmas). Therefore you want to include <proto/...>. |
21 December 2017, 14:59 | #7 | |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
Aarrrgh! Sorry. I misunderstood your question. Ignore my previous posting!
Quote:
EDIT: Do not use m68k-kick13 with a 3.x SDK! Otherwise you are calling for trouble. m68k-kick13 is designed to be used with the original 1.3 SDK from the 80s. Last edited by phx; 21 December 2017 at 15:07. Reason: 1.3 SDK |
|
03 January 2018, 20:24 | #8 | |
dev
|
Quote:
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Looking for Cool Pointers | squidbass | Amiga scene | 2 | 27 March 2015 12:12 |
Arcade: Joystick Assignment Issue. | Jason H | support.FS-UAE | 1 | 31 March 2014 23:07 |
2 Mouse Pointers!!! | wandeep | support.WinUAE | 3 | 21 May 2008 13:44 |
Two mouse pointers! | mlft | support.WinUAE | 16 | 21 December 2002 02:52 |
|
|