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’t, 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)

 

Tim

 

From: Mcdaniel, Daryl [mailto:daryl.mcdaniel@intel.com]
Sent: Tuesday, April 29, 2014 10:36 AM
To: edk2-devel@lists.sourceforge.net
Subject: Re: [edk2] A compile fail problem when I include stdio.h into the cpp file

 

You mention a cpp file.  Are you trying to build this with C++?

Have you included StdLib\StdLib.inc in your project’s .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’s 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’t follow the instructions in that file, builds with StdLib will either fail or will not work as expected.

 

Sincerely,

Daryl McDaniel

 

"Mistakes are the portals of discovery"

-- James Joyce

 

 

From: w.j.wang (王為之) [mailto:w.j.wang@gigabyte.com]
Sent: Thursday, April 24, 2014 8:52 PM
To: edk2-devel@lists.sourceforge.net
Subject: [edk2] A compile fail problem when I include stdio.h into the cpp file

 

Hello everyone,

 

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.

 

Thanks,