gpt4 book ai didi

c - 'this' 未声明(在此函数中首次使用)

转载 作者:太空宇宙 更新时间:2023-11-04 05:20:36 25 4
gpt4 key购买 nike

我是 C 的新手,使用 Mingw32 编译器。现在我正在创建从 IL 到 C( native )的反编译器

生成的代码(没有 System.Object):

DecompileTestApplication_Program.c

#include "DecompileTestApplication_Program.h"
DecompileTestApplication_Program* DecompileTestApplication_Program__ctor( ) {
if (array__DecompileTestApplication_Program == 0) {
array__DecompileTestApplication_Program=(void**)malloc(sizeof(void*)*(capacity__DecompileTestApplication_Program=4));
}
DecompileTestApplication_Program* this;
//error: 'this' undeclared (first use in this function)
if (count__DecompileTestApplication_Program==0) {
this=(DecompileTestApplication_Program*)malloc(sizeof(DecompileTestApplication_Program));
goto RealConstructor;
}
this=(DecompileTestApplication_Program*)array__DecompileTestApplication_Program[--count__DecompileTestApplication_Program];
RealConstructor:
this->ind = 0;
this->a = 1;
this->b = 3;
//this._inherit_object_( ); //this is OOP tests ,still working on it
return this;
}
void DecompileTestApplication_Program_Main( ) {
int var_0_02;
var_0_02 = 0;
var_0_02 = ( var_0_02 + 1 );
int var_1_08;
var_1_08 = 1;
int var_2_0A;
var_2_0A = 3;
var_1_08 = ( var_1_08 + var_2_0A );
var_0_02 = ( var_0_02 + ( var_1_08 + var_2_0A ) );
DecompileTestApplication_Program_blat = ( DecompileTestApplication_Program_blat + ++DecompileTestApplication_Program_bpa );
}
void DecompileTestApplication_Program__cctor( ) {
DecompileTestApplication_Program_blat = 1;
DecompileTestApplication_Program_bpa = 4;
}

DecompileTestApplication_Program.h

#ifndef DecompileTestApplication_Program
#define DecompileTestApplication_Program
/*
Type's Name: DecompileTestApplication.Program
Time to Parse: 40.0023ms
*/
#include <stdio.h>
typedef struct {
//Variables
int ind;
int a;
int b;
} DecompileTestApplication_Program;
static int DecompileTestApplication_Program_blat;
static int DecompileTestApplication_Program_bpa;
//Methods
void DecompileTestApplication_Program_Main( );
DecompileTestApplication_Program* DecompileTestApplication_Program__ctor( );
void DecompileTestApplication_Program__cctor( );
static int count__DecompileTestApplication_Program=0;
static int capacity__DecompileTestApplication_Program=0;
static DecompileTestApplication_Program** array__DecompileTestApplication_Program=0;
#endif

@main.h

void main();

@main.cpp

//bookmart for includes
#include "DecompileTestApplication_Program.h"


void main() {
//bookmark for initialize
DecompileTestApplication_Program__cctor();
DecompileTestApplication_Program_Main();
}

在第一个文件中发现错误。我搜索了一段时间这个错误的解决方案,但没有找到。

最佳答案

#define DecompileTestApplication_Program

这意味着无论你在哪里看到单词 DecompileTestApplication_Program,它都会被删除。因此,您尝试声明 this:

DecompileTestApplication_Program* this;

扩展为

* this;

它试图取消引用未声明的变量 this。要解决此问题,请更改宏名称。

关于c - 'this' 未声明(在此函数中首次使用),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11469760/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com