LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

CVI 8.5 __FUNCTION__ Macro missing

Hi,

I just installed CVI 8.5 and tried to compile one of our projects that is using the __FUNCTION__, __FILE__ and __LINE__ macros for creating error messages. The __FILE__ and __LINE__ macros are compiled, but the __FUNCTION__ macro is not found by the compiler and creates an error.


Steven
0 Kudos
Message 1 of 29
(11,173 Views)
__FUNCTION__ (or more properly __func__) I think is a C99 feature, although it was implemented in other compilers, of course, previously. CVI is not C99 compliant - as has been discussed before.
--
Martin
Certified CVI Developer
0 Kudos
Message 2 of 29
(11,167 Views)
Hi,

I don't quite understand that the __FUNCTION__ macro is not working, because it worked well in CVI 8.1.1.


Steven
0 Kudos
Message 3 of 29
(11,188 Views)
Steven,
 
As Martin mentioned, the __FUNCTION__ macro is not part of the ANSI C 89 standard. It is part of the C99 standard, and CVI isn't C99-compatible. What happened in 8.5 was that a handful of the features that comprise the C99 standard were added (note: for those of you who have shown interest in C99 and CVI, please be aware that CVI 8.5 is nevertheless still not C99-compatible).
 
Because code that uses C99 features might not be compatible with other C compilers, in order to use any of the C99-specific features of CVI 8.5, you will have to add a new pragma to your code:
 
   #pragma iso_9899_1999
 
Since __FUNCTION__ is really a C99 feature, it is now also grouped with the other features that require the use of this pragma. Actually, to be more precise, the C99 standard calls for "__func__", not "__FUNCTION__". But both should work in CVI 8.5. So, to answer your question directly, yes you can continue to use __FUNCTION__ but you'll have a line with this pragma somewhere above the use of the macro.
 
In case anyone is interested, these are the other features that are present in CVI 8.5, the use of which is governed by this pragma:
 
1. Declaring variables in the middle of a block. For example:
 
{
    int i = 1;
    printf ("%d", i);
    int j = 2;
    printf ("%d", j);
    for (int k = 0; k < i + j; ++k)
        printf ("%d", k); /* k is out-of-scope after the for-loop */
    printf ("%d", i + j);
}
 
2. Macros with variable arguments. For example:
 
     #define debug_printf(format,...) fprintf (stderr, format, __VA_ARGS__);
 
3. Allocating memory on the stack (alloca call).
 
4. Support for the long long data type (this is functionally identical to the already existing __int64), and its associated functions (strtoll, lldiv, etc...)
 
Luis

 
Message 4 of 29
(11,158 Views)
Is it possible to make use of  #pragma iso_9899_1999  depending on the CVI version?
How can be used in combination with _CVI_ (850) macro defined by CVI?
0 Kudos
Message 5 of 29
(11,079 Views)

Solution found:

#if defined (_CVI_) && (_CVI_ > 850)
 #pragma iso_9899_1999
#endif

0 Kudos
Message 6 of 29
(11,039 Views)
Does 8.5 have anything for IEEE 1754 support?    With CVI most everyone is horsing floating point values around a lot and C99 offers some refinements that are worthwhile and I wouldn't think all that hard to implement.

Menchar
0 Kudos
Message 7 of 29
(11,012 Views)
Menchar,
 
Could you be more specific about what those enhancements are? My copy of the C99 standard does not mention IEEE 1754. Do you mean maybe IEEE 754?
 
Thanks,
Luis


Message Edited by LuisG on 11-26-2007 03:42 PM
0 Kudos
Message 8 of 29
(11,005 Views)

Luis -

Yup, 754-1985 it is. 

Menchar 

0 Kudos
Message 9 of 29
(11,002 Views)
Thanks a bunch for the information about the C99 enhancements, but can somebody please tell me why I have to stumble upon this by pure chance here in the forum instead of reading about it in the release notes? Isn't that what the notes are for, for deity's sake? On the bright side, these are exactly the C99 features I had on the wish list I gave to an NI developer earlier last year 🙂

Message Edited by MarcelK on 01-09-2008 02:48 PM
0 Kudos
Message 10 of 29
(10,506 Views)