What does the “undefined reference to varName” in C mean?

后端 未结 6 1581
粉色の甜心
粉色の甜心 2020-12-01 18:32

I have 2 files: a.c and b.c

In a.c I am sending a signal to a function located in b.c

signal(SIGU         


        
6条回答
  •  离开以前
    2020-12-01 18:48

    It is very bad style to define external interfaces in .c files. .

    You should do this

    a.h

        extern void doSomething (int    sig);
    

    a.c

        void doSomething (int    sig)
        {
           ... do stuff 
        }
    

    b.c

    #include "a.h"
    .....
    signal(SIGNAL, doSomething); 
    

    .

提交回复
热议问题