LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

link issues with external compiler

Solved!
Go to solution

Hi,

 

when I try to compile my source with an external compiler, I do get various warnings and errors.

 

One is

 

"mbsupp.h"(29,1)   (29): error: invalid redeclaration of type name "size_t"
"mbsupp.h"(29,1)   typedef unsigned int size_t;

This include file mbsupp.h is included by ansi_c.h, because in my source, I have the following

 

#include <analysis.h>
#include <ansi_c.h>
#include <cvirte.h>    
#include <formatio.h>
#include <userint.h>
#include <utility.h>

So now the important question, how do I resolve this issue? Do I have to change the order of some included files?

 

Thanks,

 

Wolfgang

0 Kudos
Message 1 of 9
(6,199 Views)

Hello Wolfgang

 

For this looks like a problem related to the external Compiler used here. I tried to compile a simple Sourcecode with these include Statements using Microsoft Compiler and it was working fine. So witch specific Compiler do you use?

 

Like you already suggested, its worth a try to change the order of the include files. For example place ansi_c.h at the en.

Another option may be to add a IF Statement in the "mbsupp.h" to avoid redeclaration.

 

Regards

Moritz M.

0 Kudos
Message 2 of 9
(6,166 Views)

Thank you, Moris M.,

 

yes, the problem is related to the external compiler, it works fine with CVI. The external compiler is the Intel icl 11. I will try the include permutations as suggested.

 

Thanks,

 

Wolfgang

0 Kudos
Message 3 of 9
(6,150 Views)

Hi all,

 

I have tried rearranging the sequence of include files, with no success.

 

But actually I am wondering why the following code is included in mbsupp.h:

 

#ifndef _SIZE_T_DEFINED
#define _SIZE_T_DEFINED
typedef unsigned int size_t;
#endif

 

The problem with these lines is that the Intel compiler is complaining about the invalid redeclaration of size_t

 

so here is my question:

 

Obviously, using the standard CVI compiler, this declaration does not cause any problems, so it might be related to the fact that the intel compiler is both a C and a C++ compiler. Did anybody using any external C/C++ compiler experience (and solve) this problem?

 

Since the use of Intel compilers is sort of supported by NI I am wondering if someone is familiar with this topic? Hopefully 🙂

 

Thanks!

Wolfgang 

0 Kudos
Message 4 of 9
(6,102 Views)

It is possible that the Intel compiler already has its own internal definition of size_t and is therefore confused by the typedef. If so, you should easily solve your problem, by including the following line in your source file, before all the #includes:

 

#define _SIZE_T_DEFINED

 

This will stop the subsequent typedef from being compiled in error. Or, it may be something else...

 

JR

0 Kudos
Message 5 of 9
(6,100 Views)

Hi JR,

 

thanks for your suggestion! However, it does not solve the problem, it only modifies it...

 

1) In case I am using the CVI compiler, I end up with a missing parameter type (of course), so obviously some more refined macro is required; how could one distinguish between an internal and an external compiler?

 

2) For the Intel compiler, compilation now works, however I end up with a link error

 

 Undefined symbol '_main' referenced in "c:\program files (x86)\national instruments\cvi90\bin\Msvc\cvistart.lib".

 

Maybe you have an idea how to solve this, too?

Thanks, Wolfgang

0 Kudos
Message 6 of 9
(6,091 Views)

There is a pre-defined macro which can be used to determine if you are in a CVI compilation or not - like this:

 

#ifndef _CVI_

#define _SIZE_T_DEFINED

#endif

 

Not sure I can help much with the link problem - it seems to have found the library file (usually the problem in similar circumstances is a missing file) but perhaps you need to select between the VisualC and BorlandC library compatibility modes? I've never experimented with an external compiler so I'm not aware of any common pitfalls.

 

JR

Message 7 of 9
(6,085 Views)
Solution
Accepted by topic author Wolfgang

OK,

 

I have resolved the isssue...

 

First, I have installed a newer version of the compiler, 11.1.035 instead of 11.0.61. Second, I have chosen a different compiler (Intel offers both 32 and 64 bit and Itanium), obviously now the correct one, because I have the feeling that this caused the trouble.

 

Anyway, thanks to all contributors!

 

Wolfgang

0 Kudos
Message 8 of 9
(6,084 Views)

Hi JR,

 

Many thanks for your information on the macro - obviously your answer appeared while I was typing my solution... 🙂

 

Wolfgang

 

 

0 Kudos
Message 9 of 9
(6,077 Views)