Dear Daryl and Tim,

 

Thanks for your reply.

I found out the wchar_t type also causes another compiler fail problem when I use the Print (IN CONST CHAR16  *Format,…) function, the error message as shown in the below:

error C2664: 'Print': cannot convert parameter 1 from 'const wchar_t [13]' to 'const CHAR16 *'

I just print out the hello world with new line, the reason Daryl has mentioned.

Thus, I have another question, does this problem can be solved when I use GCC or Intel compiler instead of VC compiler?

 

Sincerely,

Wei

 

From: Tim Lewis [mailto:tim.lewis@insyde.com] 
Sent: Tuesday, April 29, 2014 11:06 AM
To: edk2-devel@lists.sourceforge.net
Subject: Re: [edk2] A compile fail problem when I include stdio.h into the cpp file

 

Daryl –

 

Could we simply remove the .cpp rules from the build_rules? It makes people unnecessarily confused, since C++ is not officially supported. It prevents getting an “file type not supported” from the INF processing and instead gives esoteric C compiler issues.

 

Tim

 

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

 

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 [mailto:tim.lewis@insyde.com] 
Sent: Tuesday, April 29, 2014 11:06 AM
To: edk2-devel@lists.sourceforge.net
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)

 

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,