Duplicate Symbol Error involving a struct

My code is a little too long to put here.

Somewhere in the implementation file of my base class I am causing the duplicate symbol error below:

ld: duplicate symbol _pressureTable in /var/folders/8t/hqtf6z356sdfn9hcrzhf75s00000gn/T//ccwhIMIX.o and /var/folders/8t/hqtf6z356sdfn9hcrzhf75s00000gn/T//ccFpslXQ.o for architecture x86_64

Here is the pressureTable struct:

struct tableData
{
double sat_value;
double v_f;
double v_g;
double u_f;
double u_g;
double u_fg;
double h_f;
double h_g;
double h_fg;
double s_f;
double s_g;
double s_fg;
} pressureTable, temperatureTable;

Examples of what I am doing with the struct:

tableData ThermodynamicPowerCycle::UseSaturatedWaterPressureTable(float pressure)
{
while(true) {
int number = pressureMap.count(pressure);
if(number == 1) {
pressureTable = pressureMap.find(pressure)->second;
return pressureTable;
} else {
AppendSaturatedWaterPressureTable(pressure);
}
}

}

void ThermodynamicPowerCycle::AppendSaturatedWaterPressureTable(float pressure)
{
std::cout << "Would you like to manually specifically enter values (1) or enter two sets for interpolation (2)?" << std::endl;
short choice;
do {
std::cin >> choice;
}while(choice < 1 || choice > 2);
for(int i=0; i<choice; i++) {
std::cout << "For Pressure: " << pressure << ":" << std::endl;
std::cout << "Input the saturation temperature in Celsius" << std::endl;
std::cin >> pressureTable.sat_value;
std::cout << "Input specific volume for fluid phase and vapor phase in m3/kg. e.g. 0.01 5" << std::endl;
std::cin >> pressureTable.v_f >> pressureTable.v_g;
std::cout << "Input internal energy for fluid phase and vapor phase in kJ/kg" << std::endl;
std::cin >> pressureTable.u_f >> pressureTable.u_g;
std::cout << "Input enthalpy for fluid phase and vapor phase in kJ/kg" << std::endl;
std::cin >> pressureTable.h_f >> pressureTable.h_g;
std::cout << "Input entropy for fluid phase and vapor phase in kJ/kg*K" << std::endl;
std::cin >> pressureTable.s_f >> pressureTable.s_g;

pressureTable.u_fg = pressureTable.u_g - pressureTable.u_f;
pressureTable.h_fg = pressureTable.h_g - pressureTable.h_f;
pressureTable.s_fg = pressureTable.s_g - pressureTable.s_f;

pressureMap[pressure] = pressureTable;
}

if(choice == 2) {
Interpolate(pressure, pressureMap);
}
isSWPTappended = true;
}



As you may see, I am constantly redefining the struct and associating it with a map defined as:


std::map<float,tableData> pressureMap, temperatureMap;



I'm not seeing any thing risky here but maybe I'm not aware of it. This is my first time using a technique like this. I can post more code if it would help, however most of it is along these lines. Any help would be greatly appreciated. Thanks.
Did you define pressureTable twice or more by mistake?

Also, wrap your code inside [code]code tags[/code] to make it easier to read (syntax highlighting)
To my knowedge, pressure table is only defined once in header file as:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
struct tableData
{
double sat_value;
double v_f;
double v_g;
double u_f;
double u_g;
double u_fg;
double h_f;
double h_g;
double h_fg;
double s_f;
double s_g;
double s_fg;
} pressureTable, temperatureTable;
So I got this problem fixed. Apparently the error is in the last line. The struct should be modified to be:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
struct tableData
{
    double sat_value;
    double v_f;
    double v_g;
    double u_f;
    double u_g;
    double u_fg;
    double h_f;
    double h_g;
    double h_fg;
    double s_f;
    double s_g;
    double s_fg;
};


e.g. not defining "pressureTable" and "temperatureTable" in the last line of the struct definition. I defined the

 
tableData pressureTable;

locally in each function, not trying a singular definition in the header file; although I expect that will work.

Topic archived. No new replies allowed.