LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How to override a utility.h function

Hopefully, this is a simple one. 
 
I am using utility.h and windows.h functions.  I want to use GetSystemTime from windows.h, not utility.h.  But, since windows.h must be the first include, GetSystemTime from utility.h is compiled, not the one from windows.h.
 
How do I override this?
0 Kudos
Message 1 of 5
(3,920 Views)
Yes, NI has "stepped on" this Win32 function.  I don't think this is the only Win32 function they've done this with but it's the one everyone wants to use.

One way to deal with it is to use a separate module (i.e. file) that includes the code you want to have call GetSystemTime and #include only windows.h (GetSystemTime is defined in winbase.h, included within windows.h) and not include utility.h

Or you could edit the NI header file to eliminate the NI function prototype so that CVI discovers the Win32 prototype in windows.h

Or you could redefine just the Win32 Get System Time function in the module where you wish to use it.  Do this after the #include utility.h

Here it is:

WINBASEAPI
VOID
WINAPI
GetSystemTime(
    OUT LPSYSTEMTIME lpSystemTime
    );

Menchar




0 Kudos
Message 2 of 5
(3,918 Views)
Woops -

Use #undef on the NI version first ...

#undef GetSystemTime
WINBASEAPI
VOID
WINAPI
GetSystemTime(
    OUT LPSYSTEMTIME lpSystemTime
    );




CVI may wank a bit about redefining the NI function but I believe this works.

Menchar
0 Kudos
Message 3 of 5
(3,915 Views)
Menchar,

Not that this will reduce your frustration in any way, but you should keep in mind that the LabWindows Utility library has been around for almost 20 years, thus pre-dating the Win32 function name. So, this is just a minor quibble with your use of the term "step on". 🙂

Luis
NI
0 Kudos
Message 4 of 5
(3,907 Views)

Luis -

I stand corrected.   Those darn Microsoft people, what were they thinking?

Menchar

 

 

0 Kudos
Message 5 of 5
(3,903 Views)