Could you please solve my problem? looking at the code, it is self explanatory:
a.h:
#include"c.h"
void a()
{
printf("I am in a\n");
}
c.h:
#include<stdio.h>
void a();
void b();
main.c:
#include"c.h"
main()
{
a();
}
and gcc main.c will give me:
/tmp/ccuaiUEA.o: In function `main':
main.c:(.text+0x7): undefined reference to `a'
collect2: ld returned 1 exit status
Can you please help me in a way that file extensions (.h and .c) remain unchanged?
You need to rename
a.htoc.cand then build and run like this:Explanation: your
a.his a source file, not a header, so it need to have a.csuffix, not.h. Its corresponding header isc.hso by convention it should be namedc.c. When you build your executable you need to compile and link bothmain.candc.csource files, which is why they are both included in thegcccommand line.