I use gcc and unity build. When I have a piece of code in a ".a" file compiled and bundled, should I keep the "source.c" (or just the header file of "source.c") file included in the "BIG" include file that I will include in "main.c"? Will gcc recompile the "source.c" file? And how should I compile my main.c file? I saw two ways:
Like this:
gcc -o main main.c -L./ -ltest
Or like this:
gcc -o main main.c libtest.a
If I include "source.c" in the include file it compiles successfully, but how do I know that "source.c" is not getting recompiled?
EDIT: I have a source file (lib.c) I have everything included in it. (test.h and test.c) In test.h there's a function declaration (TestCall) and in test.c it's definition. Lib compiles successfully. But when I compile main.c with test.h included and libtest.a linked. Gcc throws "undefined reference to `TestCall'".
EDIT 2:
/*main.c*/
#include "test.h"
int main()
{
TestCall();
return 0;
}
/*test.h*/
#ifndef TEST_H
#define TEST_H
static void TestCall();
#endif
/*test.c*/
#include "test.h"
#include <stdio.h>
static void TestCall()
{
printf("TestCall gets called!\n");
}
I tried a command: nm libtest.a
And it says TestCall is there:
test.o:
00000000 b .bss
00000000 d .data
00000000 r .eh_frame
00000000 r .rdata
00000000 r .rdata$zzz
00000000 t .text
U _puts
00000000 t _TestCall