0

反编译TestApplication_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

反编译TestApplication_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

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

4

2 回答 2

0

在 C 中,使用标签声明结构类型不会将裸标签声明为类型(与 C++ 不同)。你所要做的:

typedef struct DecompileTestApplication_MyAnotherProgram DecompileTestApplication_MyAnotherProgram;

如果没有水平滚动条,这不适合 SO 上的一行。

或者,您必须struct每次都为标签添加前缀:

void DecompileTestApplication_Program_Plan(struct DecompileTestApplication_MyAnotherProgram*);

扩展答案

除了确保单个单词是structusing的别名typedef外,您还必须确保每种类型只有一个typedef

作为旁注,您的标头保护名称侵入了为实现保留的名称空间(这意味着,对于编写 C 编译器的人)。不要那样做。一般不要使用以下划线开头的名称,尤其不要使用以下划线或一个下划线和一个大写字母开头的名称。

在上下文中,这意味着:

反编译TestApplication_Program.h

#ifndef DecompileTestApplication_Program_header
#define DecompileTestApplication_Program_header
typedef struct DecompileTestApplication_MyAnotherProgram DecompileTestApplication_MyAnotherProgram;
typedef struct DecompileTestApplication_Program DecompileTestApplication_Program;
struct DecompileTestApplication_Program
{
    //Variables
    int ind;
    int a;
    int b;
    int __refs__;  // This is not safe either!
};
// Why is this function declared here and not in the other header?
void DecompileTestApplication_Program_Plan(DecompileTestApplication_MyAnotherProgram *prog);
#endif

反编译TestApplication_MyAnotherProgram.h

#ifndef DecompileTestApplication_MyAnotherProgram_header
#define DecompileTestApplication_MyAnotherProgram_header
#include "DecompileTestApplication_Program.h"
struct DecompileTestApplication_MyAnotherProgram
{
    //Variables
    DecompileTestApplication_Program* program;
    int __refs__;  // Dangerous
};
#endif

显然不需要标头<stdio.h>

于 2012-07-16T02:21:51.607 回答
0

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

void DecompileTestApplication_Program_Plan(struct DecompileTestApplication_MyAnotherProgram);

或者你应该使用 typedef:

typedef struct DecompileTestApplication_MyAnotherProgram DecompileTestApplication_MyAnotherProgram;

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

struct XXX.... {
};
于 2012-07-16T02:25:18.963 回答