LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

CVI 8.5 __FUNCTION__ macro cannot be used as part of string constant

Looking at this post:
 
I tried to add #pragma iso_9899_1999 to the top of my code.
 
However, during compile, the error below occurred:
 
Type error in argument 2 to 'hrCheck"; found "pointer to const char" expected "pointer to char"
     int hrCheck( HRESULT hresult, char *desc )
     ...
          hrCheck(hr, __FUNCTION__ " my post-string error message")
 
This error occurred in other error strings where I appended __FUNCTION__ to string constants, or embedded it inside other string constants.
 
void logger( char * );
...
logger( __FUNCTION__ "()- error occurred because ..." ); // fails
 
0 Kudos
Message 1 of 2
(3,054 Views)
Hi CviUser2003,

In versions prior to CVI 8.5, we implemented the __FUNCTION__ macro such that we internally returned a string (i.e. which means you can use this in places that are expecting a string).  In CVI 8.5, we changed the implementation to be more consistent with the C99 specification. This change no longer evaluates to a string and thus you receive the error.  We reverted this change in CVI 8.5.1 so that existing applications like yours will continue to work.  So your options are:
  1. Upgrade to CVI 8.5.1
  2. Use a format specifier like so:
    #pragma iso_9899_1999
    DebugPrintf ("%s", __FUNCTION__);


Best Regards,
Jonathan N.
National Instruments
0 Kudos
Message 2 of 2
(3,047 Views)