09-03-2014 05:26 PM
After migration to the LabWindows/CVI 2013 SP2 i have a trouble with a project that has been successfully built on previous version.
I'm trying to build a project in debug configuration. So, as I understand, Native CVI compiler is used.
Compilation fails in code included by ansi\stddef.h:
#ifdef __clang__
/* Avoid conflict with windows.h */
#ifdef NULL
#undef NULL
#endif
#if __clang_major__ == 2 && __clang_minor__ == 9
#include <clang/2.9/stddef.h>
#else // clang 1.0 does not define version numbers
#include <clang/stddef.h>
#endif
#define _PTRDIFF_T_DEFINED
#define _SIZE_T_DEFINED
#define _OFFSETOF_DEFINED
#ifndef __cplusplus
typedef wchar_t sdk_wchar_t;
#define _WCHAR_T_DEFINED
#endif
#endif /* __clang__ */
Problem that type name wchar_t is undefined for some reason.
Due to the preprocessor operators logic the definition should be taken from one of the following files: clang/2.9/stddef.h or clang/stddef.h .
Both mentioned files includes definition for wchar_t but either of the definition isn't used.
clang/2.9/stddef.h :
#ifndef __cplusplus
#ifndef _WCHAR_T
#define _WCHAR_T
typedef __WCHAR_TYPE__ wchar_t;
#endif
#endif
clang/stddef.h :
#ifndef __cplusplus
typedef __typeof__(*L"") wchar_t;
#endif
Can someone suggest what is the problem ?
Is it right behavior thar compiler run inside #ifdef __clang__ statement while compiling in debug configuration?
Thanks in advance!
09-04-2014 01:57 AM - edited 09-04-2014 01:58 AM
For what it's worth, I have no problems in defining and using a variable of type wchar_t.
Now, I'm very new to CVI2013 so I don't pretend to be able to explain what's happening. I'm using 2013SP1 and my configuration is the default one (I made no customizations after install): in Options >> Build Options >> Build Process Options panel Standard CVI Compiler is selected both for 32- and 64-bit configurations, __clang__ macro is not included in predefined macros and wchar_t definition is taken from [CVIdir]\include\ansi folder.
09-04-2014 04:11 AM
Roberto, thanks for your reply.
I'm very new to CVI 2013 too. I haven't changed any build configuration since installation so I have default configuration too.
As I see inside Options >> Build Options >> Build Process Options it is possible to configure compiler only for Release build configuration. But I'm trying to build a project in Debug configuration. So this option shouldn't affect my compilation process.
CVI 2013 Release Notes says that now Clang is used as a Native CVI compiler. Maybe that is the reason why even in DEBUG configuration compiler runs inside #ifdef __clang__ statement. But this conclusion makes a mash because the following link says that keyword __typeof__ is not supported anymore in CVI 2013 but exactly this keyword used in [CVIdir]\include\clang\stddef.h
http://digital.ni.com/public.nsf/allkb/73AEAD30C8AF681A86257BBB0054A26B
I also don't see __clang__ definition in compiler's predefined macroses.
It would great to hear some explanation from support guys. Because I get confused a little bit.
P.S.
Thanks a lot.
Regards.
09-04-2014 05:48 AM
Well, CVI 2013SP1 release notes tell:
The LabWindows/CVI compiler is now using the LLVM compiler infrastructure with a Clang C front end. The updated compiler generates optimized code, meaning that you no longer need to use an external optimizing compiler for this purpose.
I'm not sure about the exact meaning of all that, but it seems to me that this does not implies the use of clang compiler. In effect, in my configuration wchar_t is taken from [CVIdir]\include\ansi\ctype.h file and not in clang or clang\2.9 folders. ctype.h is included before stddef.h in ansi_c.h and does not handle __clang__ macro.
09-04-2014 05:51 AM
@RobertoBozzolo wrote:
I'm not sure about the exact meaning of all that, but it seems to me that this does not implies the use of clang compiler.
It does... While in earlier version clang was an option for the release configuration, CVI2013 now uses clang both for release and debug
09-05-2014 02:01 PM
wchar_t
is defined in \clang\2.9\stddef.h
and in \ansi\ctype.h
. You will end up using the ctype.h
definition if you include windows.h
in your application. Have you tried including windows.h
?
09-10-2014 08:24 AM
Thanks for reply.
Yes, my .c file contain #include <windows.h>. But it doesn't help me. By experiments I've found the solution to include <ansi_c.h> before <windows.h>.
But I'm not sure that this is the right way to do.
01-27-2020 08:08 AM
Strange, I'm having the same error now after recompiling an old CVI2015 project with CVI2019. wchat_t is clearly defined in other parts of the code, but missing in some. There must be some weird #undef in some parts of the headers.