Ok, now i'm getting a multiple definition error. This might be due to the inclusion of the .h files in several .c files, but if I don't do that it tells me the variables I want to use are not declared.
I'll give a few pieces of the code, maybe that'll help:
The last .c file has the error (the variable is nowhere else defined but in the constants.h).
main.c:
Code:
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include "constants.h"
#include "constant_calculations.h"
#include "initial_value_calculator.h"
int main(){
double f0_GW, r0, phi0, pr0, pphi0, m1, m2 ;
double EOB_M, nu, v_MECO, v_pole, c_array[6], omega0;
m1 = 1.0*phys_MO ;
m2 = 1.0*phys_MO ;
EOB_M = m1 + m2 ;
nu = m1*m2*pow(EOB_M,-2) ;
v_MECO = calculate_vMECO(EOB_M) ;
v_pole = calculate_vpole(nu) ;
fill_c_array() ;
//more stuff..
return 0 ;
}
constants.h:
Code:
double const phys_MO = 4.94296E-6 ;
extern double c_array[6] ;
extern double EOB_M, nu;
extern double v_MECO, v_pole ;
extern double omega0;
constant_calculations.c:
Code:
#include <stdlib.h>
#include <math.h>
#include "constants.h"
double EOB_M, nu, v_MECO, v_pole, c_array[6], omega0;
//functions including calculate_vMECO(EOB_M), calculate_vpole(nu) and fill_c_array()
//fill_c_array() uses other functions which use nu inside (not in the arguments)
initial_value_calculator.c:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "constants.h"
#include "hamiltons_equations.h"
#include "reaction_force.h"
double EOB_M, nu, v_MECO, v_pole, c_array[6], omega0;
double z(double r, int diff) { //ERROR: It says at this line that it detects a multiple definition of 'phys_MO'
double Ar,Ar_prime,X1,X2,dX1,dX2 ;
Ar = calculate_Ar(r,0) ;
Ar_prime = calculate_Ar(r,1) ;
X1 = pow(r,3) * pow(Ar,2) ;
X2 = pow(r,3) - 3*pow(r,2) + 5*nu ;
dX1 = 2*pow(r,2)*pow(Ar,2) + 2*pow(r,3) * Ar * Ar_prime ;
dX2 = 3*pow(r,2) - 6*r ;
switch(diff) {
case 1:
return dX1/X2 - (X1/pow(X2,2)*dX2) ;
default:
return X1/X2 ;
}
}
//more functions