LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

multiple definitions problem

Hello, I have a problem of multiple definitions. In my project I have created a *.h file in which I have declarated some global tables that are used by different *.c files. In those *.c files I have included the Table.h file but when I compile the project an error of multiple symbol definition occurs. How can I avoid this problem? Thanks in advance
0 Kudos
Message 1 of 6
(4,444 Views)

Hi Aldart,

is it possible to post you project in an attachment? If you do not want to share your entire project, try to strip it down to the problem...

0 Kudos
Message 2 of 6
(4,418 Views)
Hi aldart,

may be you have to add the following lines to your h-file:

At the beginning of the file:

#ifndef TABLE_H
#define TABLE H

then following:
your declared tables

and at the end of the file:

#endif

Good luck

Norbert Rieper


"aldart" <x@no.email> schrieb im Newsbeitrag
news:1189010414298-575594@exchange.ni.com...
> Hello, I have a problem of multiple definitions. In my project I have
> created a *.h file in which I have declarated some global tables that are
> used by different *.c files. In those *.c files I have included the
> Table.h file but when I compile the project an error of multiple symbol
> definition occurs. How can I avoid this problem? Thanks in advance


0 Kudos
Message 3 of 6
(4,413 Views)
ups, missed a underscore in Line 2: should be #define TABLE_H instead of
#define TABLE H



#ifndef TABLE_H
#define TABLE_H

then following:
your declared tables

and at the end of the file:

#endif

"Norbert Rieper" <nrieper@isitec.de> schrieb im Newsbeitrag
news:46dfcede$1@PYROS.natinst.com...
> Hi aldart,
>
> may be you have to add the following lines to your h-file:
>
> At the beginning of the file:
>
> #ifndef TABLE_H
> #define TABLE H
>
> then following:
> your declared tables
>
> and at the end of the file:
>
> #endif
>
> Good luck
>
> Norbert Rieper
>
>
> "aldart" <x@no.email> schrieb im Newsbeitrag
> news:1189010414298-575594@exchange.ni.com...
>> Hello, I have a problem of multiple definitions. In my project I have
>> created a *.h file in which I have declarated some global tables that are
>> used by different *.c files. In those *.c files I have included the
>> Table.h file but when I compile the project an error of multiple symbol
>> definition occurs. How can I avoid this problem? Thanks in advance
>
>


0 Kudos
Message 4 of 6
(4,412 Views)
Thanks for your replies. I had already inserted those lines, Table.h file seems something like this:

#ifndef __DAB_Table_H__
#define __DAB_Table_H__

int Table1[48][5]=....
int Table2[48][5]=....
....
....

#endif

but I had the same problem. I have solved by creating a Table.c file in which I have inserted the tables' definition and in the Table.h file I have left only the tables' declaration
0 Kudos
Message 5 of 6
(4,401 Views)

The CVI linker does not support multiply defined symbols. This happen when you include a header file that contain declarations and the header files is included in several source files. To avoid this, you should include the header only once and then declare the variables as externals in the other files.

 

0 Kudos
Message 6 of 6
(4,368 Views)