Since C++ isn’t supported, I won’t comment on that.


If the directions for StdLib are followed, /Zc:wchar_t- will be set for the Microsoft compiler.  (Note the trailing minus (-).  This turns off intrinsic support for wchar_t)  The equivalent is done, where necessary, for other compilers and other intrinsics.


wchar_t is particularly problematic since VC++ treats wchar_t as a specific, distinct, type.  Any attempt to redefine it, even to an equivalent type, will fail.

Sometimes the failure shows up during compilation.  Most often it fails during the link and code generation phase; a result of LTCG.


Daryl McDaniel


"It is the mark of an educated mind to be able to entertain a thought without accepting it."

– Aristotle


From: Tim Lewis []
Sent: Tuesday, April 29, 2014 11:06 AM
Subject: Re: [edk2] A compile fail problem when I include stdio.h into the cpp file


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)




From: Mcdaniel, Daryl []
Sent: Tuesday, April 29, 2014 10:36 AM
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\ 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.



Daryl McDaniel


"Mistakes are the portals of discovery"

-- James Joyce



From: (王為之) []
Sent: Thursday, April 24, 2014 8:52 PM
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.