As I said, im getting this type of error in my current program(Working in C with CodeBlocks IDE mingw 64):
C:\msys64\mingw64\bin..\lib\gcc\x86_64-w64-mingw32\10.1.0........\x86_64-w64-mingw32\bin\ld.exe: obj\Debug\main.o:C:\Users\lgmfo\Desktop\SimpleDiet\simplediet.h|1|multiple definition of `matrixSize'; obj\Debug\filesManager.o:C:/Users/lgmfo/Desktop/SimpleDiet/simplediet.h:1: first defined here|
I really dont have a clue of what exactly is going on, because the entire code was working just fine untill I played with the values of some random variable(it has nothing to do with the header file).
My header file looks like this:
int matrixSize[2], nReal, nPosible;
float *targetParameters;
float **diets;
void Inspector(void);
int Combinations(int);
void MatrixSelector(int *, int, int, int);
void ViableDiets(int *, float *, int);
void NutritionPlan(void);
void GaussJordan(float matrix[][2*matrixSize[0]], float *, int);
void Menu(void);
void MergeDiets(void);
void PrintDiets(void);
As you might already guess, my program is structured in separate files, and the following is the filesManager
file( this is the file where im getting the error, but i assume that it is the same for all of them):
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include"simplediet.h"
void Inspector(void){
FILE *fp;
int c;
int conti = 0, contj = 0;
if((fp = fopen("TablaNutricionalPlatillos.txt","r")) == NULL){
printf("No se puede abrir el archivo %s\n", "TablaNutricionalPlatillos.txt");
}
else{
while((c = getc(fp)) != EOF){
if((c == '.') && (contj == 1)){
conti++;
}
else if(c == '\n'){
contj++;
}
}
}
fclose(fp);
matrixSize[0] = conti;
matrixSize[1] = contj;
}
The message says that im defining multiple times the variable matrixSize, but i´m really not(based in the fact that it was working fine before this happended) because in the simpleDiet.h
file i'm just declaring the variables, not defining them. So I really dont know what is causing the problem here. I think it has nothing to do with the actual code but the linkers or the compiler(I´m not really an expert in all of this)
Thanks