LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

LabWindows 2015 warnings

Hello all,

I just received CVI 2015 and I'm trying to recompile one of my projects with it. I receive some new warnings. Some justified, others less so. Yes, I know I can make error messages disapear, but I rather just fix them !

 

First one is that whenever I use #include <windows.h> I get the following:

 

 WaveFile.c - 5 warnings
      7, 1   In file included from c:\Users\dargaud\Devel\Sodar\Sodar2016\Source\WaveFile.c:7:
  "Windows.h"(213,1)   In file included from C:\Program Files (x86)\National Instruments\Shared\MSDTRedistributables\SDKHeaderFiles\8.1\windows.h:213:
  "windef.h"(24,1)   In file included from C:\Program Files (x86)\National Instruments\Shared\MSDTRedistributables\SDKHeaderFiles\8.1\windef.h:24:
  "minwindef.h"(182,1)   In file included from C:\Program Files (x86)\National Instruments\Shared\MSDTRedistributables\SDKHeaderFiles\8.1\minwindef.h:182:
  "winnt.h"(5320,19)    warning: cast from function call of type 'LONG' (aka 'long') to non-matching type 'PVOID' (aka 'void *') [-Wbad-function-cast]
  "winnt.h"(5345,19)    warning: cast from function call of type 'LONG' (aka 'long') to non-matching type 'PVOID' (aka 'void *') [-Wbad-function-cast]
  "winnt.h"(8682,19)    warning: cast from function call of type 'LONG' (aka 'long') to non-matching type 'PVOID' (aka 'void *') [-Wbad-function-cast]
  "winnt.h"(8693,19)    warning: cast from function call of type 'LONG' (aka 'long') to non-matching type 'PVOID' (aka 'void *') [-Wbad-function-cast]
  "winnt.h"(8704,19)    warning: cast from function call of type 'LONG' (aka 'long') to non-matching type 'PVOID' (aka 'void *') [-Wbad-function-cast]

 

Then the following pragma does not seem to work anymore:

            #pragma DisableUninitLocalsChecking

Still gives me a warning later on:

  365, 25    warning: variable 'Wave.Data.Mono16' may be uninitialized when used here [-Wuninitialized]

 

Also the following code now gives me a warning:

 

void OutputLogMsg(const char *fmt, ... ) {
   ...
   va_start( str_args, fmt );
   Nb=vsnprintf(Msg, 1022, fmt, str_args);
66, 29    warning: format string is not a string literal [-Wformat]

Reading around I apparently need to use the following:

__attribute__((__format__ (__printf__, 3, 0)))

But it generates:

  42, 16    error: 'format' attribute parameter 2 is out of bounds

0 Kudos
Message 1 of 11
(5,620 Views)

I can comment on your first issue which is very similar to my observation here which was considered in need of a corrective action Smiley Wink

0 Kudos
Message 2 of 11
(5,616 Views)

Thanks. I'd searched for those keywords without success.

 

For my 3rd issue, I was using the wrong syntax and I fixed it.

0 Kudos
Message 3 of 11
(5,614 Views)

The 2nd issue still remains.

 

I noticed something else: I cannot [Generate Help from Source] in HTML anymore, from the documentation tags. Nothing happens. I've tried clean/rebuild and setting/removing this option. I can get a (tiny / wrong ?) XML file that I don't know how to use.

0 Kudos
Message 4 of 11
(5,572 Views)

Gdargaud,

 

I just wanted to clarify the situation to make sure that we all understand what the second issue. The #pragmaDisableUninitLocalsChecking is not working as specified.

 

Just to cover the immediate basis, do you enable the UninitLocalChecking later on in the code after you disable it? Just because the pragma will only operate on the code that is surrounds.

 

Have you been able to get other #pragma statements working on the computer? The following link has a bunch of #pragma statements that are supported by CVI: http://zone.ni.com/reference/en-XX/help/370051P-01/cvi/programmerref/pragmas/. If you are able to get other statements working, that means at least that these statements are a least being handled properly by the compiler and the issue is that specific statement.

 

Also is there a way to attach a screenshot of the code that you are working with, so we all can see the flow of the code.

Sarina
Applications Engineering
National Instruments
0 Kudos
Message 5 of 11
(5,528 Views)

Hello StarSarina,

yes, I have

#pragma DisableUninitLocalsChecking
for (i=0; i<N; i++) 	Wave.Data.Mono16[i]=SomeFunc();
SomeOtherFunc(Wave);
#pragma EnableUninitLocalsChecking

And it still gives me that warning.

I have some other pragmas in my prog, but based on #pragma clang diagnostic push / ignored / pop

0 Kudos
Message 6 of 11
(5,436 Views)

Hello gdargaud!

 

I appreciate your feedback regarding CVI 2015. I would like to request from you that you provide a minimal but fully compilable code snippet that reproduces the problem in CVI 2015. The Uninitialized Locals compiler mechanism performs analysis of the entire local scope of the uninitialized variable in order to determine whether a warning diagnostic should be emitted. Providing a compilable code snippet helps us reproduce the problem and determine a workaround.

 

Best regards!

- Johannes

0 Kudos
Message 7 of 11
(5,427 Views)

I've just upgrade my CVI2009 projects to CVI2015. This small function code is well-comipled w/o any warning in CVI2009. How to fix this compiler's bug?

 

// .................................................................................
// int __stdcall YMDHMS2DateTime(char *as_YMDHMS,char *as_DTstr)    
// Conver ByteArray YMDHMS[6] to yyyy/mm/dd hh:mm:ss where Y=YYYY-2000
// BCD--> i.e. Y: 0x11 -->Convert Hex to Dec 10 + 1 = 11 + 2000 = 2011
//Application: MMSP01/02 Sunion RFID Lock
// .................................................................................
int __stdcall eaiYMDHMS2DateTimeStr(unsigned char *as_YMDHMS,unsigned char *as_DTstr)
{
    int  val[6];
    int  li_idx, nb[2];
    unsigned char *P;
    
    P = as_YMDHMS;
    
    if (strlen(P)==0) return 0;
    
    for (li_idx=0; li_idx < 6; li_idx++) {
         val[li_idx] = (int) *P++;
         nb[0]  = val[li_idx] / 16;
         nb[1]  = val[li_idx] % 16;
         val[li_idx] = nb[0] * 10 + nb[1];
    }
    
    sprintf(as_DTstr,"%04d/%02d/%02d %02d:%02d:%02d",val[0] + 2000,val[1],val[2],val[3],val[4],val[5]);
        
    return 1;   //ok
}

//Above function is well-compile in CVI 2009, while has lots of warning in CVI2015

//compiler warning message are as followings

Build Status (FastLibDLL90.prj - Release)
 FastLibDLL90.c - 128 warnings
  2132, 19    warning: variable 'val[li_idx]' may be uninitialized when used here
      2122, 5    note: variable 'val' is declared here
  2137, 54    warning: variable 'val[0]' may be uninitialized when used here
      2122, 5    note: variable 'val' is declared here
  2137, 68    warning: variable 'val[1]' may be uninitialized when used here
      2122, 5    note: variable 'val' is declared here
  2137, 75    warning: variable 'val[2]' may be uninitialized when used here
      2122, 5    note: variable 'val' is declared here
  2137, 82    warning: variable 'val[3]' may be uninitialized when used here
      2122, 5    note: variable 'val' is declared here
  2137, 89    warning: variable 'val[4]' may be uninitialized when used here
      2122, 5    note: variable 'val' is declared here
  2137, 96    warning: variable 'val[5]' may be uninitialized when used here
      2122, 5    note: variable 'val' is declared here
      
      
      
  ...
      
      
      
 Link FastLibDLL90.dll
 "e:\CVI15\1proj\FastLibDLL90\FastLibDLL90.dll" successfully created.
 "e:\CVI15\1proj\FastLibDLL90\FastLibDLL90.lib" successfully created.
 "e:\CVI15\1proj\FastLibDLL90\msvc\FastLibDLL90.lib" successfully created.
 "C:\Windows\SysWoW64\FastLibDLL90.dll" successfully created.
Build succeeded.

 

 

 

0 Kudos
Message 8 of 11
(4,315 Views)

Just found out: if you use the __attribute__ thing in a DLL, e.g. add a function like this to the CVI DLL sample,

 

DLLEXPORT void   __stdcall DLLFunc3 (const char *fmt, ...) __attribute__((format(printf, 1, 2)));

the resource compiler freaks out

 

Build Status (cvidll.prj - Debug)
 Resource compiler errors
  Microsoft (R) Windows (R) Resource Compiler Version 6.3.9600.17200   
  Copyright (C) Microsoft Corporation.  All rights reserved.   
    
  c:\[...]\Documents\National Instruments\CVI2015\samples\dll\basic\cvibuild.cvidll\Debug\resources.out.rc(47) : error RC2104 : undefined keyword or key name: printf   
Build failed.

Smiley Frustrated

 

 

Anyway...

 

@Jedidiah

a) I'd change "char *as_YMDHMS" to "const char *as_YMDHMS" (bonus point for coding style)

b) kill the for loop and just use a sprintf, like

sprintf(as_DTstr,"20%02x/%02x/%02x %02x:%02x:%02x",as_YMDHMS[0],as_YMDHMS[1],as_YMDHMS[2],as_YMDHMS[3],as_YMDHMS[4],as_YMDHMS[5]);

(not tested)

-----------------------
/* Nothing past this point should fail if the code is working as intended */
0 Kudos
Message 9 of 11
(4,299 Views)

Try to put the __attribute__ before the function name. I've had this problem a few days ago, but I'm not sure on which compiler it helped !

0 Kudos
Message 10 of 11
(4,296 Views)