This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

C51 v8.17a stddef.h error

In my project I include stddef.h but find error on __CX2__

it's a bug or not

I try to modify it to
#if defined (__CX2__)
and passed.

what mains about __CX2__ ?

Parents
  • But I can confirm that it most certainly does!

    The following code builds with no errors & no warnings using the C51 Evaluation version 8.16a:

    #include <stdio.h>
    #include <stddef.h>
    
    void main( void )
    {
            printf( "Hello, world\r\n" );
    }
    

    After updating to the C51 Evaluation version 8.17a, the following warning is given:

    Build target 'Target 1'
    compiling main.c...
    C:\BIN\KEIL\C51\INC\STDDEF.H(21): warning C322: unknown identifier
    linking...
    Program Size: data=30.1 xdata=0 code=1080
    "Project1" - 0 Error(s), 1 Warning(s).
    

    The content of STDDEF.H in the C51 Evaluation version 8.17a, with the offending line highlighted, is:

    /*--------------------------------------------------------------------------
    STDDEF.H
    
    Standard definitions.
    Copyright (c) 1988-2004 Keil Elektronik GmbH and Keil Software, Inc.
    All rights reserved.
    --------------------------------------------------------------------------*/
    
    #ifndef __STDDEF_H__
    #define __STDDEF_H__
    
    #ifndef NULL
     #define NULL ((void *) 0)
    #endif
    
    #ifndef _SIZE_T
     #define _SIZE_T
     typedef unsigned int size_t;
    #endif
    
    #if __CX2__
    typedef int    ptrdiff_t;
    #else
    typedef long   ptrdiff_t;   // changed to 'long' due to 'far' pointer support
    #endif
    #define offsetof(s,m)   (size_t)&(((s code *)0)->m)
    
    #endif
    

    The full description of the warning message is:
    "Description The identifier in an #if directive line is undefined (evaluates to FALSE)."

    So it looks like this is an error in the updated stddef.h - the "#if" should be "#ifdef" or "#if defined"...

    Also, __CX2__ is undocumented.

Reply
  • But I can confirm that it most certainly does!

    The following code builds with no errors & no warnings using the C51 Evaluation version 8.16a:

    #include <stdio.h>
    #include <stddef.h>
    
    void main( void )
    {
            printf( "Hello, world\r\n" );
    }
    

    After updating to the C51 Evaluation version 8.17a, the following warning is given:

    Build target 'Target 1'
    compiling main.c...
    C:\BIN\KEIL\C51\INC\STDDEF.H(21): warning C322: unknown identifier
    linking...
    Program Size: data=30.1 xdata=0 code=1080
    "Project1" - 0 Error(s), 1 Warning(s).
    

    The content of STDDEF.H in the C51 Evaluation version 8.17a, with the offending line highlighted, is:

    /*--------------------------------------------------------------------------
    STDDEF.H
    
    Standard definitions.
    Copyright (c) 1988-2004 Keil Elektronik GmbH and Keil Software, Inc.
    All rights reserved.
    --------------------------------------------------------------------------*/
    
    #ifndef __STDDEF_H__
    #define __STDDEF_H__
    
    #ifndef NULL
     #define NULL ((void *) 0)
    #endif
    
    #ifndef _SIZE_T
     #define _SIZE_T
     typedef unsigned int size_t;
    #endif
    
    #if __CX2__
    typedef int    ptrdiff_t;
    #else
    typedef long   ptrdiff_t;   // changed to 'long' due to 'far' pointer support
    #endif
    #define offsetof(s,m)   (size_t)&(((s code *)0)->m)
    
    #endif
    

    The full description of the warning message is:
    "Description The identifier in an #if directive line is undefined (evaluates to FALSE)."

    So it looks like this is an error in the updated stddef.h - the "#if" should be "#ifdef" or "#if defined"...

    Also, __CX2__ is undocumented.

Children