C header issue: #include and “undefined reference”

前端 未结 5 608
无人共我
无人共我 2021-02-03 22:14

Alright, I\'ve been trying to work with this for the longest time, and I simply can\'t seem to get it to work right. I have three files, main.c, hello_world.c

5条回答
  •  面向向阳花
    2021-02-03 22:34

    gcc main.c hello_world.c -o main
    

    Also, always use header guards:

    #ifndef HELLO_WORLD_H
    #define HELLO_WORLD_H
    
    /* header file contents go here */
    
    #endif /* HELLO_WORLD_H */
    

提交回复
热议问题