02-23-2011 02:20 AM
Hello all,
no question, just a hint to avoid a pitfall I ran into...
If you are using C99 features, be aware that the definitions such as INFINITY or NAN will not be available for an external compiler such as clang.
This is because these definitions (in math.h) are preceded by
#if _CVI_C99_EXTENSIONS_
For an external compiler this condition is FALSE; hence switching to an external compiler one will get errors due to undeclared identifiers.
This of course can be avoided by adding
#ifndef NAN
#define NAN 0xCp125f
...
#endif
to an include file.
A nicer solution would be a modified if clause in the math.h file, or defining _CVI_C99_EXTENSIONS_ for external compilers, but this would be left to NI...
Solved! Go to Solution.
02-23-2011 03:11 PM
Hi Wolfgang,
A better solution would be to modify your clang interface in order to define _CVI_C99_EXTENSIONS_ when C99 is enabled.
You do this by adding /D_CVI_C99_EXTENSIONS_ to the C99 Flags field in the Options>>Build Options>>Build Process Options>>...>>Edit>>Advanced dialog box.
Because CVI can't assume that a given 3rd party compiler supports C99, it can't always define that macro when using a 3rd party compiler. But it uses the C99 flags field in the compiler interface specification to define an option that it can use for a given compiler, when C99 is enabled for the project configuration. If that field isn't blank, it means that the compiler supports C99, which means that it's also okay to define that macro.
The clang template should have included the /D_CVI_C99_EXTENSIONS_ definition. Sorry about that.
Luis
02-24-2011 01:03 AM
Dear Luis,
a better solution is always welcome
I have tried your suggestion but somehow it didn't work:
what I did: in the field C99 Flags I have added your text, so now the field reads --std=c99 /D_CVI_C99_EXTENSIONS_
however, compilation yields an error: error reading '/D_CVI_C99_EXTENSIONS_'
after investigating the issue the correct and hence even better solution seems to be to modify the field as follows:
C99 Flags: --std=c99 -D _CVI_C99_EXTENSIONS_
(that is, you have missed a space after the D and confused the slash with the minus)
This way I can omit my extra header and compilation seems to succeed.
As you have already mentioned, it would be nice if the ecc files could be updated accordingly
02-24-2011 10:35 AM
You're right, I was using CVI's /D syntax, but I should have been using the -D clang syntax. However, it shouldn't have required whitespace between -D and the variable. That part is odd. But I guess it's not all that important, in any case.
Luis