Discussion Forum

C51 v8.17a stddef.h error

Next Thread | Thread List | Previous Thread Start a Thread | Settings

DetailsMessage
Read-Only
Author
Macro Kwan
Posted
24-Dec-2008 01:59 GMT
Toolset
C51
New! 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__ ?

Read-Only
Author
Dan Henry
Posted
24-Dec-2008 04:29 GMT
Toolset
C51
New! RE: C51 v8.17a stddef.h error

"... but find error on __CX2__"

What error?

Read-Only
Author
Andy Neil
Posted
24-Dec-2008 07:12 GMT
Toolset
C51
New! RE: what mains about __CX2__ ?

Have you looked it up in the Manuals?

It isn't mentioned here:

http://www.keil.com/support/man/docs/c51/c51_pp_predefmacroconst.htm

Are there no comments in the file to guide you?

Is this a standard Keil stddef.h, or have you obtained it from a 3rd party?

As Dan says, you need to show precisely what error(s) you are getting: copy and paste the entire message - don't try to manually re-type it.

Before doing that, Have you looked-up the message in the Manuals?

http://www.keil.com/support/man/docs/c51/c51_errors.htm

Read-Only
Author
Macro Kwan
Posted
24-Dec-2008 15:53 GMT
Toolset
C51
New! RE: what mains about __CX2__ ?

The error message is
warning C322: unknow indentifier

so I think the stddef.h of Ver 8.17a is error
but other version's stddef.h is passed

You can see Ver8.17a's stddef.h for detail

The macro define of __CX2__ is a new iddentifier in VER8.17a

Thanks

Read-Only
Author
Per Westermark
Posted
24-Dec-2008 16:03 GMT
Toolset
C51
New! RE: what mains about __CX2__ ?

Wouldn't it have helped if you had posted this declaration?

It obviously isn't the __CX2__ symbol that is unknown or missing, since preprocessor symbols are not unknown or missing. Just what they possibly expand to.

Keil want me to fill in too much information for me to be interested in checking what the currently available version is.

Read-Only
Author
IB Shy
Posted
24-Dec-2008 19:27 GMT
Toolset
C51
New! RE: what mains about __CX2__ ?

Here (I think) is the fragment that the OP is talking about:

#if __CX2__
typedef int    ptrdiff_t;
#else
typedef long   ptrdiff_t;   // changed to 'long' due to 'far' pointer support
#endif

This block appears to have been added in the latest release 8.17a

Read-Only
Author
Dan Henry
Posted
24-Dec-2008 19:57 GMT
Toolset
C51
New! RE: what mains about __CX2__ ?

"The error message is
warning C322: unknow indentifier"

That's a warning message, not an error message.

The preprocessor should not be warning about unknown identifiers. Identifiers unknown to the preprocessor are replaced with zero (0) as the constant expression evaluated for the #if directive.

Read-Only
Author
Andrew Neil
Posted
29-Dec-2008 02:37 GMT
Toolset
C51
New! RE: The preprocessor should not be warning about unknown identifiers.

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.

Read-Only
Author
Al Bradford
Posted
29-Dec-2008 02:47 GMT
Toolset
C51
New! RE: The preprocessor should not be warning about unknown identifiers.

Has any one fired off a bug report to Keil Tech Support?
Bradford?

Read-Only
Author
Dan Henry
Posted
29-Dec-2008 04:44 GMT
Toolset
C51
New! RE: The preprocessor should not be warning about unknown identifiers.

"But I can confirm that it most certainly does!"

What is your opinion regarding whether it should or should not issue a warning in this case?

Read-Only
Author
Andy Neil
Posted
29-Dec-2008 07:09 GMT
Toolset
C51
New! RE: What is your opinion

I accept what you say that this is a preprocessor issue - so the compiler, strictly speaking, has no business making any comment about it.

But I think a warning here is helpful, and this particular warning has obviously been created for this very case!

http://www.keil.com/support/man/docs/c51/c51_c322.htm

In fact warnings 321-327 all seem to be to do with preprocessor issues...

Read-Only
Author
Andy Neil
Posted
29-Dec-2008 07:13 GMT
Toolset
C51
New! RE: warnings 321-327 all seem to be to do with preprocessor issues...

They are also at the very end of the list of diagnostics - which suggests they are (relatively) new and, perhaps, relatively untested...

Maybe this was actually a test-case for warning 322 that slipped into the release...

;-)

Read-Only
Author
Hans-Bernhard Broeker
Posted
2-Jan-2009 02:37 GMT
Toolset
C51
New! RE: What is your opinion

preprocessor issue - so the compiler, strictly speaking, has no business making any comment about it.

Not quite, since the preprocessor is built into the compiler these days. Strictly speaking the compiler, while outputting a diagnostic about this, is the preprocessor.

Read-Only
Author
Reinhard Keil
Posted
7-Jan-2009 07:42 GMT
Toolset
C51
New! RE: What is your opinion

CX2 is a new mode for SmartCards that is currently in development. The new STDLIB file accicently went into the release without carefully checking of the impact.

Correct is:

#ifdef __CX2__

Next Thread | Thread List | Previous Thread Start a Thread | Settings