
I'm realizing after the fact that Visual Studio has a tendency to be a personal royal pain in the, well you know where; even after enforcing strict ANSI the code worked just fine in VS but I'm having an odd problem with GDCC concerning pointers.
Code: Select all
//
// This prototype specifies a double pointer (pointer to pointer) as an argument
//
void zSys_nINST_ExtHandler (nWND *, bool, bool *, bool, unsigned short, bool, nWND **, bool, unsigned short, MSGS);
- nWND - structure, often sent to functions via pointer
- MSGS - enum (ie, message), usually controls function switch/case blocks
Code: Select all
//
// This snippet shows a typical call to the function
//
nWND * zGibZone_Detect (void)
{
bool hChk = false;
int mse_x, mse_y,
enwd_glx, enwd_gly, enwd_grx, enwd_gry;
unsigned short nwdCnt = ZERO;
nWND *enwd = NULL,
*rnwd = NULL;
zSys_nINST_ExtHandler(NULL_NWNDp, true, &hChk, false, ZERO, false, &NULL_NWNDp, true, &nwdCnt, MSG_NULL);
if(hChk == true && nwdCnt > ZERO)
{
for(int i = nwdCnt -= ONE; i > ZERO; i--)
{
zSys_nINST_ExtHandler(NULL_NWNDp, true, &hChk, false, i, true, &enwd, false, NULL_LWORDSp, MSG_GET);
if(hChk == true)
{
. . . further function beyond . . .
- NULL_NWNDp is a pointer of type nWND (structure pointer) which should point to NULL_NWND, a structure of the same type.
While the function doesn't actually have a return that is meaningful, the arguments give the function access to a group of important variables and options that can be modified;
the function allows for the storage and retrieval of the address of a structure, which is useful in instances where a function is not given a structure to work with as one of it's
arguments (ie, the snippet). In the case where the function is used to retrieve a structure address the double pointer argument is the pointer to the pointer that should be set
to the address of the structure (yes quite roundabout).
In question is the argument sporting the flashy double pointer (pointer to pointer); while this worked fine in Visual Studio, as shown in the snippet, this does not seem to impress
GDCC. I receive the following error, which is quite confuzzling:
Of course that's the first call to the function. Initially this was a different error because I was not sending the pointer address to the double pointer. While this snippet is basedGDCC wrote:ERROR: src/zgibz.c:50:24: cannot implicitly convert to arithmetic type from non-arithmetic type
make: *** [bin/zgibz.ir] Error 1
on the original code built in Visual Studio, I did comment my way down to the code from Visual Studio which has similar calls and produced the same error. So I'm left quite stumped
as to what is actually wrong here and just how to fix it. Any insight is deeply appreciated, I wasn't expecting this function to be a problem.