c 通过前向声明相互包含

标签 c

DecompileTestApplication_Program.h

#ifndef _DecompileTestApplication_Program_
#define _DecompileTestApplication_Program_
struct DecompileTestApplication_MyAnotherProgram;
#include <stdio.h>
typedef struct {
    //Variables
    int ind;
    int a;
    int b;
    int __refs__;
} DecompileTestApplication_Program;
void DecompileTestApplication_Program_Plan( DecompileTestApplication_MyAnotherProgram* );
//error: expected ')' before '*' token
#endif

DecompileTestApplication_MyAnotherProgram.h

#ifndef _DecompileTestApplication_MyAnotherProgram_
#define _DecompileTestApplication_MyAnotherProgram_
struct DecompileTestApplication_Program;
#include <stdio.h>
typedef struct {
    //Variables
    DecompileTestApplication_Program* program;
    int __refs__;
} DecompileTestApplication_MyAnotherProgram;
#endif

这又是我的 IL(C#\VB 编译代码)到 C 反编译器。 我尝试了几种方法来做到这一点,但没有获得任何成功的编译。 顺便说一句,我使用 Dev-Cpp 与原始 C 进行编译。

最佳答案

这是 C,不是 C++。声明/定义结构体不会创建新的类型名称。因此,第一个文件中的函数声明应该是

void DecompileTestApplication_Program_Plan(struct DecompileTestApplication_MyAnotherProgram);

或者你应该使用 typedef:

typedef struct DecompileTestApplication_MyAnotherProgram DecompileTestApplication_MyAnotherProgram;

在这种情况下,您必须省略第二个文件中的 typedef 关键字,只留下

struct XXX.... {
};

关于c 通过前向声明相互包含,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11497350/

相关文章:

c - SQLite C API,可以打开数据库但不使用查询返回任何数据吗?

无法读取字符串的字符,除了第一个从 r 调用 c 过程的字符

c - 指向 char 到 char 数组的指针

c - 用阿基米德方程逼近 Pi

python - Gcc、Python 和 Google 计算器中的大 float 计算错误

c - 哪个更可能浪费更少的内存,一个大内存管理器还是几个小内存管理器?

c - 仿真文件系统 (Windows)

android - "-fpermissive"和 "include "在 linux c 编译器中不起作用

c - 内核模块中的调试堆栈溢出

编译其他人的使用 math.h 的 C 程序