圖片
A.c
//
// Created by clou on 2024/4/29.
//
#include <stdio.h>
#include "A.h"
void func() {
printf("hello world\n");
}
A.h
//
// Created by clou on 2024/4/29.
//
#ifndef MULTIPLE_SOURCE_FILES_A_H
#define MULTIPLE_SOURCE_FILES_A_H
extern void func();
#endif //MULTIPLE_SOURCE_FILES_A_H
B.c
//
// Created by clou on 2024/4/29.
//
#include "A.h"
#include "B.h"
//extern void func(); //如果包含了A.h 該宣告可以省略
void func2() {
func(); //呼叫A.c 中的函式func
}
B.h
//
// Created by clou on 2024/4/29.
//
#ifndef MULTIPLE_SOURCE_FILES_B_H
#define MULTIPLE_SOURCE_FILES_B_H
extern void func2();
#endif //MULTIPLE_SOURCE_FILES_B_H
main.c
//
// Created by clou on 2024/4/29.
//
#include "B.h"
int main() {
func2();
return 0;
}