I have 3 files, they are main.c, Test.c, Test.h. This is what in inside those main.c
#include <stdio.h>
#include <stdlib.h>
#include"Test.h"
int main()
{
test_function();
return 0;
}
Test.c
#include<stdio.h>
#include<stdlib.h>
#include"Test.h"
void __attribute__((weak)) test_function()
{
printf("Test_fuction \n");
getchar();
}
Test.h
#ifndef TEST_H
#define TEST_H
#include<stdio.h>
void __attribute__((weak)) test_function();
#endif // TEST_H
and this is my build process
gcc -c main.c -o main.o
gcc -c Test.c -o Test.o
gcc main.o Test.o -o main
from what i have learnt, the weak function would be used if user didn't redefine it. In my program i didn't redefine it, supposedly when the function is call in my main, it should print "Test_function" to the screen. But nothing happened when i run main.exe, the promt was opend then closed several seconds later. Could anybody tell me what i'm doing wrong here.
Thank you so much