It has been my observation that this occurs because the current build rules include the .cpp extension with the .c extension. This forces C++ files to be compiled with the C rules. In the x86 tool chains, this almost works because the tool chain auto-detects the type of compilation to perform based on the extension (in ARM RVTOOLS it doesn$B!G(Bt, if my memory serves me right).
However, when you get the StdLib you run into one of the issues: wchar_t. In C++ this flag is turned on by default. In C it is not. EfiCDefs.h is trying to make sense of this, but does not consider the C++ case. If _NATIVE_WCHAR_T_DEFINED is set, it means that /Zc:wchar_t was used (or C++ was compiled)
Have you included StdLib\StdLib.inc in your project$B!G(Bs .dsc file?
The error you are seeing was added to EfiCdefs.h to detect configuration errors. When it occurs, you can be sure that your project$B!G(Bs build files are not configured correctly.
Look at StdLib\StdLib.dsc and AppPkg\AppPkg.dsc for examples of .dsc files for using StdLib.
Also, look at some of the application .inf files in AppPkg for examples of properly formed .inf files.
These files have comments describing the constructs that are specific to StdLib.
Note that C++ is not currently supported, nor is it tested.
Make sure that you have read, and understand, the StdLib\ReadMe.txt file. If you don$B!G(Bt follow the instructions in that file, builds with StdLib will either fail or will not work as expected.
"Mistakes are the portals of discovery"
-- James Joyce
I have met a compile problem when I include stdio.h into the cpp file.
The error message is:
c:\myworkspace\StdLib\Include\sys/EfiCdefs.h(330) : fatal error C1189: #error :
You must specify /Zc:wchar_t- to the compiler to turn off intrinsic wchar_t.
Hence, I followed the tip to add the /Zc:wchar_t- into the BuildOptions of my inf file.
However, this compile error still occurs, unless I direct delete the 330 line of the EfiCdef.h.
It seems an issue.