LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

CVI 8.5 __FUNCTION__ Macro missing

Marcel,
 
The very limited C99 features in CVI 8.5 are undocumented, and not officially supported. This is why they weren't included in the release notes.
 
Luis
0 Kudos
Message 11 of 29
(3,447 Views)
Well, in that case I'm glad I still found it here... I was almost going to recommend skipping 8.5 in my company because the effort of updating all the PCs and production facilities seemed not worth the trouble. But for THOSE few features I'd do it myself if need be 😉 Shame such simple things as snprintf are still not there.
0 Kudos
Message 12 of 29
(3,424 Views)

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

Should be:

#if defined (_CVI_) && (_CVI_ >= 850)            /* LabWindows/CVI 8.5 or greater? */
 #pragma iso_9899_1999                                /* enable ANSI C 89 features */
#endif

 

0 Kudos
Message 13 of 29
(3,229 Views)

I can't get the C99 features to work even after using the pragma. 

#pragma iso_9899_1999

I can't declare a variable in the middle of a block for example.

Menchar

0 Kudos
Message 14 of 29
(3,063 Views)
Did you place the pragma before the declarations?
 
#pragma iso_9899_1999
void foo (void)
{
    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);
}
See if this code here compiles for you. If this one does, but yours doesn't, can you post yours, so that I can try it out?
 
Thanks,
Luis
0 Kudos
Message 15 of 29
(3,034 Views)
Luis -
 
I think the problem was that I had originally used it this way as first described by NI
 
#if defined (_CVI_) && (_CVI_ > 850)      
  #pragma iso_9899_1999
#endif
 
instead of    ...     (_CVI >= 850)    
as pointed out in a previous post.
 
Thanks, it works now.
 
Menchar
 
 


Message Edited by menchar on 05-22-2008 09:42 AM
0 Kudos
Message 16 of 29
(3,052 Views)

Menchar,

I'm glad it's working now.

But for the record, we (NI) only identified the pragma itself, not the conditions that should surround it. Smiley Wink

Luis

0 Kudos
Message 17 of 29
(3,037 Views)
Well, that isn't the end of it as it turns out 🙂
 
I can't do this:
 
#pragma iso_9899_1999
 
typedef int MYINTTYPE;
 
MYINTTYPE j;    // OK
 
int myFunc ()  {
 
MYINTTYPE iStatus1;  // OK
 
  while (1) {
 
    ;
 
    MYINTTYPE  iMyInt = 0;  // fails
 
    {  MYINTTYPE  iMyInt = 0; }     // OK
    int i = 0;  // OK
 
  }
 
}
 
Why can't I use a typedef in a C99 intra-block declaration?  
 
It's as if the preprocessor isn't expecting to find and expand a type def used in a variable declaration anywhere but at the top level or at the beginning of a block.
C99 doesn't default an omitted type to int the way C89 does, but there is a type here if the preprocessor would expand it.
 
Menchar


Message Edited by menchar on 05-22-2008 04:54 PM
0 Kudos
Message 18 of 29
(3,028 Views)
I would have expected it to work, but I've confirmed what you saw. Apparently, typedef'd variables can't be declared in the middle of the block, even with C99 enabled.
 
This will be fixed in the next version. Sorry about that.
 
If, in the meanwhile, I find out about some workaround to make it work in 8.5, I'll post it here.
 
Luis
0 Kudos
Message 19 of 29
(3,007 Views)

Well, you're not officially supporting the C99 stuff, and I would have guessed that there'd be some implementation issues, unless you have a very rigorous validation suite it's easy to miss side-effects when making compiler changes.

As best as I can tell, that should have worked.  Probably need to tweak the pre-processor - I looked at the expanded source and the typedef's not getting expanded, so the compiler then gags on the non-native type.

I had been in the habit of using Win32 data types (e.g. INT, HANDLE, CHAR, BYTE, DWORD, UCHAR, etc.) to simplify interaction with the Win32 SDK - the SDK uses these types, and they can be used in CVI by including windows.h (which includes windef.h and winbase.h).

Menchar

0 Kudos
Message 20 of 29
(3,006 Views)