Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I remove TOOLBOX.C warnings under VC++ 7.0 (.NET)

When I include TOOLBOX.C into my VC++ 7.0 (.net) project, I get tons of warnings (see below)
- the main ones are:
== warning C4005: 'THREAD_BASE_PRIORITY_MIN' : macro redefinition
== warning C4005: 'THREAD_BASE_PRIORITY_IDLE' : macro redefinition

If I change the warning level, most will go away. However, why do they exist at all?
- I have to play with the order of <#include>: sometimes this works, sometimes it doesn't
0 Kudos
Message 1 of 3
(3,023 Views)
Hello

For the problem with the macro definitions, apparently WinNt.h and cvidel.h does define this. The values for these defines are the same, so it should not effect the code. To get rid of this macro error, you can move the the following section to the top of the header list

#if _NI_mswin32_
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include

The reason this is happeing with VS.NET and not with CVI is that CVI's version of the platform SDK is customize to work with CVI. CVI's version of the Windows SDK was a massive effort that was required to make it compatible with an ANSI C compiler. There was alot of stuff like inline assembly, 64 bit integers and such that CVI does not support (CVI 7.0 now has 64 bit ints). You
can go to the WinNt.h file located in the CVI folder, and you will notice that it looks different that the file that ships with Visual Studio 7.x. We do ofcourse make sure that all the SDK functionality is present in the version of the SDK that ships with CVI.

With warning level 3 ( which is the default), i did not get any of the other errors you mentioned. But level 4 did throw the warnings. Most of the warning are just to make the programmer aware of situations that might cause errors at run-time. For example, One of the errors i got was

ox\testtoolbox\toolbox.c(10800) : warning C4706: assignment within conditional expression

and the statement was

if (!(retVal = GetSHELL32FuncsIfNeeded ()))

The compiler wants to make sure you were actaully doing an assignment and that you didnt actaully want to do a comparison ( == instead of = ).

But all the syntax is valid, its just a matter of code readability and correctness. As long as the developer knows his code, he woul
d not need to worry about such minor warnings.

I hope this explains things

Bilal Durrani
NI
Bilal Durrani
NI
0 Kudos
Message 2 of 3
(3,023 Views)
I am using LabWindows/CVI version 6.0. It already had your code snippet at the top of the file. And it generated the same warnings.
- like you mentioned, these are just warnings and since the #define are the same, it should not impact my application
- I got the same output when I changed it to error level 3 (no warnings found).

//////////////////////////////////////////////////////
#ifndef HAVE_CVI_RTE
#define HAVE_CVI_RTE 1
#endif


#include
#include
#include
#if _NI_mswin32_
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include
#include
#endif /* _NI_mswin32 */
#include
#include
#if _NI_mswin16_ || _NI_mswin32_
#include
io.h>
#endif /* _NI_mswin16 || _NI_mswin32_ */
#include "toolbox.h"

#if !HAVE_CVI_RTE
int __CVI_SystemCodePage = 0;
#endif

//////////////////////////////////////////////////////
0 Kudos
Message 3 of 3
(3,023 Views)