LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I make a Define.h without have "Redeclaration" Errors

I have made a Define.h where I declare a enum Constant. My problem is that the compiler shows redeclaration errors when including this h-File in several C-Files. How must I define my type-declaration of "lpdata" in the attached file?
0 Kudos
Message 1 of 4
(3,820 Views)
I integrated your header file into a project of mine without any error.
So in my opinion you are linking in your source code other header files that contains a symbol already present in your header file.

You could try changing the order of the header files or comment them one by one in your source code to detect where the duplicate definition is.

Roberto


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 4
(3,820 Views)
Well, the problem is the following: I have a project which is splitted in several dll's. For example subproject A and B (I just call it subproject but in real it is a single cvi-project). In a c-file from subproject A I am using functions of subproject B. In subproject B I have to include the "ustpdef.h" in some headerfiles which contain function prototypes. In subproject A I also have headerfiles (for example "exampleA.h") in which I have to include the "ustpdef.h". In "exampleB.c" from subproject A I am now calling a function of subproject B. So when compiling, the compiler includes the "ustpdef.h" twice. Now I would like to write a macro in the "ustpdef.h" which only defines the enum constant if not already defined. Hope you understand my problem....;-)
0 Kudos
Message 3 of 4
(3,820 Views)
You could try adding:

#ifndef (THIS_IS_MY_MEANINGFULL_HEADER_FILE)
#define THIS_IS_MY_MEANINGFULL_HEADER_FILE

place all your definitions here

#endif // End of THIS_IS_MY_MEANINGFULL_HEADER_FILE


This can stop the file being called many times. Its good practice to do this, and sometimes improves the compile time on large projects considerably.

Anything within the file is only called once, since on the next pass THIS_IS_MY_MEANINGFULL_HEADER_FILE has already been defined and so it jumps out of the header file.

Regards

Chris
Message 4 of 4
(3,820 Views)