Properly including header file

I continually get tons of these errors below when trying to include my header file:
" :1>Check_l1_a1_r1.obj : error LNK2005: "
"struct EMT (* myemt)[5]" (?myemt@@3PAY04UEMT@@A) already defined in Check.obj"
The header file consists of structures that are later accessed in my function check.cpp. The function check is called from within another function. Any help or guidance in debugging this is appreciated as always. Thanks.
Note the function check is defined in header file structs.h

Data.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
  #ifndef DATA_H
#define DATA_H

#include <iostream>
#include <string>


struct EMT
{
	int pipesizeEmt;
	float bendRadiusEmt;
	float shoeDimensionEmt;
	float conduitDimensionEmt;
	float tailEmt;
};
	EMT myemt[10][5] =
	{ 12,  5.883, 2.973, 0.530, 48.000,
	  34, 6.000, 2.480, 0.692, 48.000,
	 100, 7.000, 2.990, 0.872, 48.000,
	 114, 8.500, 3.662, 1.133, 46.500,
	 112, 8.500, 3.662, 1.305, 46.500,
	 200, 9.250, 3.610, 1.648, 46.500,
	 212, 12.000, 4.180, 2.156, 46.500,
	 300, 16.000, 7.544, 2.625, 53.750,
	 312, 18.625, 7.518, 3.000, 53.750,
	 400, 20.875, 7.277, 3.375, 53.750
	};

	struct RIGID
	{
		int pipesizeR;
		float bendRadiusR;
		float shoeDimensionR;
		float conduitDimensionR;
		float tailR;

	};
	RIGID myrigid[10][5] =
	{ 12,  5.950, 2.562, 0.875, 48.000,
	  34, 6.937, 3.264, 0.875, 48.000,
	 100, 7.000, 3.434, 1.165, 48.000,
	 114, 8.500, 4.111, 1.285, 48.000,
	 112, 8.500, 4.239, 1.530, 48.000,
	 200, 9.000, 4.314, 1.781, 48.000,
	 212, 12.000, 4.180, 2.000, 46.500,
	 300, 16.000, 7.544, 2.000, 53.750,
	 312, 18.625, 7.518, 2.500, 53.750,
	 400, 20.875, 7.277, 2.500, 53.750
	};

	struct IMC
	{
		int pipesizeI;
		float bendRadiusI;
		float shoeDimensionI;
		float conduitDimensionI;
		float tailI;
	};

	IMC myimc[10][5] =
	{
	  12,  5.950, 2.562, 0.875, 48.000,
	  34, 6.937, 3.264, 0.875, 48.000,
	 100, 7.000, 3.434, 1.165, 48.000,
	 114, 8.500, 4.111, 1.285, 48.000,
	 112, 8.500, 4.239, 1.412, 48.000,
	 200, 9.000, 4.314, 1.770, 48.000,
	 212, 12.000, 4.180, 2.000, 46.500,
	 300, 16.000, 7.544, 2.000, 53.750,
	 312, 18.625, 7.518, 2.500, 53.750,
	 400, 20.875, 7.277, 2.500, 53.750
	};

	struct ALRIG
	{
		int pipesizeA;
		float bendRadiusA;
		float shoeDimensionA;
		float conduitDimensionA;
		float tailA;
	};

	ALRIG myalrig[10][5] =
	{
	  12,  5.950, 2.562, 0.875, 48.000,
	  34, 6.937, 3.264, 0.875, 48.000,
	 100, 7.000, 3.434, 1.165, 48.000,
	 114, 8.500, 4.111, 1.285, 48.000,
	 112, 8.500, 4.239, 1.425, 48.000,
	 200, 9.000, 4.314, 1.781, 48.000,
	 212, 12.000, 4.180, 2.000, 46.500,
	 300, 16.000, 7.544, 2.000, 53.750,
	 312, 18.625, 7.518, 2.500, 53.750,
	 400, 20.875, 7.277, 2.500, 53.750,
	};

	struct SSRIG
	{
		int pipesizeS;
		float bendRadiusS;
		float shoeDimensionS;
		float conduitDimensionS;
		float tailS;
	};

	SSRIG myssrig[10][5] =
	{
	  12,  5.950, 2.562, 0.875, 48.000,
	  34,  6.937, 3.264, 0.875, 48.000,
	 100,  7.000, 3.434, 1.165, 48.000,
	 114,  8.500, 4.111, 1.285, 48.000,
	 112,  8.500, 4.239, 1.425, 48.000,
	 200,  9.000, 4.314, 1.781, 48.000,
	 212, 12.000, 4.180, 2.000, 46.500,
	 300, 16.000, 7.544, 2.000, 53.750,
	 312, 18.625, 7.518, 2.500, 53.750,
	400, 20.875, 7.277, 2.500, 53.750,
	};
#endif  


Function that calls my function check
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;

#include "Structs.h"
#include "Data.h"

void checkLAR(char name[32], float num1, float num2, float num3, char eol[16], ostream &outputFile, string pipeType, int pipesize)
{
	bool flag = true;
	flag = check(num1, num2, pipeType, pipesize); // check algorithm 

	if (strcmp(name, larName) != 0)
	{
		flag = false;
	}

	if (isdigit(num1)) 
	{
		if ((num1 < 0.0) || (num1 > 60.0))
		{
			flag = false;
		}
	}

	if (isdigit(num2)) // check a1
	{

		if ((num2 < 5.0) || (num2 > 90.0))
		{
			flag = false;
		}
	}


	if (isdigit(num3)) // check r1
	{
		if ((num3 < -90.0) || (num3 > 180.0))
		{
			flag = false;
		}
	}
	
	if (strcmp(eol, larEol) != 0)
	{
		flag = false;
	}
	
	if (!flag)
	{
		outputFile << "()" << ",";
	}

	if (flag) // if no error found move on to next error check ie checkl2_a2_r2
	{
		outputFile << ",";
	}
}
That's because the code in a header file is just pasted into any file that uses it.

You need header files to provide type definitions, but you're declaring variables. When that code is pasted into source files, you get the same variables declared in multiple source files. The linker spots the error and complains.

You should move the declarations in a source file. If they have to be shared across modules, you need to use the extern keyword in a header file.
https://jameshfisher.com/2017/08/28/c-extern-function.html
So i moved my data structures from the header file into my check function and I still get an error. "error LNK2019: unresolved external symbol "bool __cdecl check"

The check function and other function is defined within my structs.h file
1
2
bool check(float num1, float num2, string pipeType, int pipesize);
void checkLAR(char name[32], float num1, float num2, float num3, char eol[16], ostream &outputFile, string pipeType, int pipesize)


Then within that checkLAR function I include my structs.h and then call my check(num1, num2, pipeType, pipesize) function. Thoughts?
Topic archived. No new replies allowed.