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__ ?
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.
Has any one fired off a bug report to Keil Tech Support? Bradford?
"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?
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...
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...
;-)
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.
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__