#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2013
    Posts
    10
    Rep Power
    0

    Compiler Warnings


    Hi Guys

    I've recently been reviewing some code for that deals with data conversion, however when compiling the code more than a fair share of warning have arisen.

    Here is the code I am looking at today:

    Code:
    /* n_abidat.c : ABI / Non-ABI data conversion */
    #include <w_scr.h>
    #include "n_abidat.h"
    
    /* Macros for converting adt union fields to strings or int/long values */
    #define ANUM( s, f)     GetNum( adt.s.f, sizeof( adt.s.f))
    #define ANUML( s, f)    GetNuml( adt.s.f, sizeof( adt.s.f))
    #define ASTR( s, f, d) GetStr( adt.s.f, sizeof( adt.s.f), d)
    /*-------------------------------------------------------------------------*/
    
    extern void ReadAbiData( fh)
     FH *fh;
    {
            int x = 0;
            uchar cArea[ 6], cAlarm[ 6];
    
            cArea[ 0] = NULL; //Because cArea is set to NULL line 20 is expecting to be passed a pointer.
    
            strcpy( cArea, ConvertNpArea( G.dstdesc));              /* Read area */
            GetAreaData( fh, cArea);
    
            GetCarData( fh, veh.abicode);                           /* Read car group */
            for( x = 1; conviction.who[ x]; x++)                    /* Read convictions */
                    GetConvData( fh, conviction.desc[ x], x);
    
            for( x = 1; x <= G.noalarm; x++)                                /* Read
    security */
            {
                    if( alarm.abi[ x])
                    {
                            cAlarm[ 0] = NULL;
                            sprintf( cAlarm,"%.5d", alarm.abi[ x]);
                            GetAlarmData( fh, cAlarm, x);
                    }
                    else
                            GetNpAlarmData( fh, alarm.desc[ x], x);
            }
    
    #ifdef KF
    
            if(G.systype == TEST1|| TEST_SYS)
            {
                    for( x = 1; x <= G.nomods; x++)         /* Read Modifications */{
            GetModsData( fh, modify.abi[x], x);
                    }
            }
    #endif
    
            return;
    }
    The warning I am getting is:
    UX:i386acomp: WARNING: "n_abidat.c", line 20: warning: argument is incompatible with prototype: arg #1
    Can anyone help? I have added a comment to line 20 for what I think is the problem, I was just looking for some confirmation.

    Thanks
    Jim
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2013
    Posts
    10
    Rep Power
    0

    [SOLVED] - Compiler Warnings


    Hi Guys

    I've fixed this now, I was missing

    Code:
    #include <string.h>
    and have converted all of the NULL(s) to Zero(s) which has compiled warning and error free.

    Thanks
    Jim
  4. #3
  5. Contributing User

    Join Date
    Aug 2003
    Location
    UK
    Posts
    5,075
    Rep Power
    1802
    Originally Posted by ClouD501
    and have converted all of the NULL(s) to Zero(s) which has compiled warning and error free.
    You need not have done that, NULL is defined in <stddef.h>, which is indirectly included by most standard header files.

    That said the use of literal zero (0) rather then NULL is considered best practice in C++, where an implicit conversion to a pointer is guaranteed to result in a null pointer. The same guarantee is not made in ISO C90, I am not sure about later standards, but I'd be surprised if it was not a safe assumption for all but the most esoteric of architectures.
    Last edited by clifford; November 11th, 2013 at 01:29 PM.

IMN logo majestic logo threadwatch logo seochat tools logo