Why function must be defined with static when compiling
06:35 07 Jan 2026

I wanted to see what happens if I include the source file instead of the header file.

main.c

#include 
#include "func.c"

int main(void)
{
    printf("%d\n", call());
    return 0;
}

func.c

int call(void)
{
    return 100;
}

compilation command

cc main.c func.c -o program && ./program

error

/usr/bin/ld: /tmp/ccZZ43AI.o: in function `call':
func.c:(.text+0x0): multiple definition of `call'; /tmp/ccXvHf37.o:main.c:(.text+0x0): first defined here
collect2: error: ld returned 1 exit status

But when I change the function definition from int call(void) to static int call(void) it compiles and works. Why when defining the function with static it compiles?

c linker include definition static-functions