The structure of my codes is like:
passivertm_formal.c:
#include "CPML_profile.c"
int main(int argc, char* argv[])
{
int n1,n2;
float *p1,*p2;
n1=1;
n2=2;
p1=(float*)calloc(n1,sizeof(float));
p2=(float*)calloc(n2,sizeof(float));
CPML_profile(p1,p2);
...
}
CPML_profile.c:
#include <stdio.h>
#include <math.h>
void CPML_profile(float *p1, float *p2)
{
extern int n1,n2;
...
}
But when I compile the two codes, error shows:
CPML_profile.o: In function `CPML_profile':
CPML_profile.c:(.text+0x0): multiple definition of `CPML_profile'
passivertm_formal.o:passivertm_formal.c:(.text+0x0): first defined here
passivertm_formal.o: In function `CPML_profile':
passivertm_formal.c:(.text+0x13): undefined reference to `n1'
passivertm_formal.c:(.text+0x1b): undefined reference to `n2'
CPML_profile.o: In function `CPML_profile':
CPML_profile.c:(.text+0x13): undefined reference to `n1'
CPML_profile.c:(.text+0x1b): undefined reference to `n2'
Can anybody figure out why it happens?