LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Automatic name change??

Hi all!

Part of my project looks like this:

 - 'my_header.h' with structure definition

 - 'source1.c' with structure declaration and 'utility.h' included

 - 'source2.c' with structure imported by 'extern' and header with structure definition included

 

I made a mistake with structure declaration and one of variables was named 'inp' like function declarated in utility.h

 

I encountered a strange behavior while trying to compile project. I had a linker error named 'Inconsistent type declarations for external symbol' between 'source1.c' and 'source2.c'. When I looked into the preprocess for these two files I saw that for 'source1.c' the variable name was changed to 'CVI_inp', but remained unchanged for 'source2.c'. There was no warning in compilation. Only linker error.

 

Is there any way to change this automatic behavior or at least get a warning?

 

Any help will be greatly appreciated.

0 Kudos
Message 1 of 4
(3,332 Views)

Dear kdikus,

 

sorry for the late reply. I believe that your problem is caused by the fact that one of the source files is compiled to use the "inp" from utility.h while the other is using the one you defined. As they probably are of different types, you get the error you mentioned, as explained in Build Errors and Warnings:

Inconsistent type declarations for external symbol NAME in modules FILE1 and FILE2.
Link Error
You declared two or more external symbols with the same name but not the same type. Check each program file that contains an external declaration of the symbol for type consistency.

 

It might be easiest to change the name of the variable to be sure your program is doing what is expected.

 

If you could post a sample code showing the problem and your software versions, I would be more than happy to look into it further.

 

Have a nice day!

Zenon Kuder
Applications Engineering
National Instruments
0 Kudos
Message 2 of 4
(3,289 Views)

Dear Zenon Kuder,

You are right. I changed the name of the variable and everything works fine.

 

Originally my header file had something like this:

typedef struct
{
    FLAG valid;   
    FLAG active; 

    uint8_t inp;

    uint8_t out;  
} IOB_D3_3J43; 

 

In source file when this header was included with utility.h  "Options/Preprocess Source File" created:

#line 20 "d:\\grp\\sm\\DILA\\IOB_lib\\IOB_D3_3J43.h"
typedef struct
{
FLAG valid;  
FLAG active; 
uint8_t CVI_inp; 
uint8_t out; 
} IOB_D3_3J43;

 

 In source file when this header was included without utility.h  "Options/Preprocess Source File" created:

#line 20 "d:\\grp\\sm\\DILA\\IOB_lib\\IOB_D3_3J43.h"
typedef struct
{
FLAG valid;  
FLAG active; 
uint8_t inp; 
uint8_t out; 
} IOB_D3_3J43;

 

Then linker showed "Inconsistent type declarations" error. I was suprised that there was no warning than CVI is modifying my structure. Can You explain this "CVI_" adding mechanism?

 

I'm using CVI 9.1.0 (427).

 

Have a nice day!

0 Kudos
Message 3 of 4
(3,256 Views)

Hello!

 

Sorry for letting you wait for so long again.

 

The CVI_ adding mechanism is defined in the CVI header files and apparently is supposed to avoid naming conflicts with a different library. See ...\CVI2009\include\utility.h and search for "inp". You'll see that there is a macro adding the CVI_ prefix for several keywords in case win32 library is already in use.

 

See also this page: Resolving Conflicts Between LabWindows/CVI Functions and Interface to Win32 Application Programmatic....

 

The fact that this is defined in a macro in a header is also a reason why you don't get a warning about this. It's true that your structure variables are not in a real conflict with any of these functions, but it would probably be hard do define it in a simple macro. From the code I suspect you could turn this behavior off by defining SDK_CONFLICT_PRIORITY as described in the above link, nevertheless this is not a real solution as the option is supposed to switch you to using the Windows API functions instead of the CVI ones.

 

Generally the CVI_ prefix addition should be consistent throughout your code and therefore shouldn't affect how your program works, but only as long as your header files are defined consistently as well. In your case the utility.h, which defines the macro, is not included in one of your files, so it doesn't make the name change. Unfortunately I am not a C expert, so I am not certain if you are supposed to include the file in all of your sources or not.

 

I hope this helps and I apologize for the delay.

 

Have a great day!

Zenon

Zenon Kuder
Applications Engineering
National Instruments
0 Kudos
Message 4 of 4
(3,198 Views)