图片
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;
}
标签:FILES,调用,MULTIPLE,clou,29,C语言,源文件,SOURCE,include
From: https://www.cnblogs.com/cloucodeforfun/p/18166526