I Have included all the files in the codeblocks while making simple cosole C Application but this Error come when i define the macro. i guess linker is not able to link all files in project .i have two files included in project test1.c and test1.h code in files is as shown below..
file :::::test1.c
#include<stdio.h>
void m();
#include "test1.h"
#define DS==1
int main(){
return 0;
}
file::::test1.h
#ifndef TEST1_H_INCLUDED
#define TEST1_H_INCLUDED
#if DS ==1
void m(){
printf("hello DS==1");
}
#eliif DS==2
void main(){
printf("hello DS==2");
}
#endif
#endif // TEST1_H_INCLUDED
Error is that
**> E:\Documents\Myprojects\My C PRoj\Te\test1.c||In function 'main':|
E:\Documents\Myprojects\My C PRoj\Te\test1.c|8|warning: implicit declaration of function 'm'| obj\Debug\test1.o||In function `main':| E:\Documents\Myprojects\My C PRoj\Te\test1.c|8|undefined reference to `m'| ||=== Build finished: 1 errors, 1 warnings ===|**
if i remove the conditional macro an compile simply with following code:
file:::::test1.c
#include<stdio.h>
#include "test1.h"
int main(){
m();
return 0;
}
file:::::test1.h
#ifndef TEST1_H_INCLUDED
#define TEST1_H_INCLUDED
void m(){
printf("uncoditional macro");
}
#endif // TEST1_H_INCLUDED
every thing works fine .what is reason for that?