BOOL未被识别为数据类型(C ...?)

时间:2016-09-24 00:30:13

标签: c

我正在尝试使用Visual Studio 2015 Enterprise从源代码编译应用程序。我遇到了一些问题。

当我尝试编译时,我得到几个与BOOL相关的错误是一个未定义的类型。我试过包括winmindef.h和windef.h无济于事。以下是代码中抛出错误的一些函数声明:

void GetCheatName          ( int CheatNo, char * CheatName, int CheatNameLen );
BOOL LoadCheatExt          ( char * CheatName, char * CheatExt, int MaxCheatExtLen);
void RefreshCheatManager   ( void );
void SaveCheatExt          ( char * CheatName, char * CheatExt );
BOOL TreeView_GetCheckState(HWND hwndTreeView, HTREEITEM hItem);
BOOL TreeView_SetCheckState(HWND hwndTreeView, HTREEITEM hItem, BOOL fCheck);`

当我在.h文件中包含以下内容时,问题仍然无法解决

#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif

typedef int BOOL;

如果有帮助,我正在尝试编译PJ64,可能需要更改一些设置才能编译,但我不确定是哪一个。

任何帮助都表示赞赏!

--- --- UPDATE

以下是完整的编译错误(我省略了大部分警告):

1>cl : Command line warning D9007: '/Gm' requires '/Zi or /ZI'; option ignored
1>  Cheat.c
1>Cheat.c(55): error C2059: syntax error: '<parameter-list>'
1>Cheat.c(56): error C2059: syntax error: '{'
1>Cheat.c(233): warning C4267: '=': conversion from 'size_t' to 'WORD', possible loss of data
1>Cheat.c(326): warning C4267: '=': conversion from 'size_t' to 'WORD', possible loss of data
1>Cheat.c(346): warning C4267: '=': conversion from 'size_t' to 'WORD', possible loss of data
1>Cheat.c(982): error C2059: syntax error: '<parameter-list>'
1>Cheat.c(998): error C2059: syntax error: '{'
1>Cheat.c(999): error C2449: found '{' at file scope (missing function header?)
1>Cheat.c(1012): error C2059: syntax error: '}'

我正在尝试编译的项目的完整代码here

这是编译的代码部分并抛出上述错误。我已经把绝大多数的代码都删掉了,因为这里的代码太长了。我留下的评论表明哪些行引发了错误。

#include <Windows.h>
#include <windowsx.h>
#include <commctrl.h>
#include <windef.h>
#include <stdio.h>
#include "main.h"
#include "cheats.h"
#include "cpu.h"
#include "resource.h"

#define UM_CHECKSTATECHANGE     (WM_USER + 100)
#define UM_CHANGECODEEXTENSION  (WM_USER + 101)
#define IDC_MYTREE              0x500

#define MaxCheats               300

#define SelectCheat             1
#define EditCheat               2
#define NewCheat                3 

HWND hManageWindow = NULL;
HWND hSelectCheat, hAddCheat, hCheatTree;
CHEAT_CODES Codes[MaxCheats];
int NoOfCodes;

void GetCheatName          ( int CheatNo, char * CheatName, int CheatNameLen );
BOOL LoadCheatExt          ( char * CheatName, char * CheatExt, int MaxCheatExtLen);
void RefreshCheatManager   ( void );
void SaveCheatExt          ( char * CheatName, char * CheatExt );
BOOL TreeView_GetCheckState(HWND hwndTreeView, HTREEITEM hItem); //(line 55, error thrown.)
BOOL TreeView_SetCheckState(HWND hwndTreeView, HTREEITEM hItem, BOOL fCheck); //(line 56)

LRESULT CALLBACK ManageCheatsProc (HWND, UINT, WPARAM, LPARAM );

void ApplyCheats (void) {
    //lots 'o code
}


BOOL CheatActive (char * Name) {
    //more code
}

LRESULT CALLBACK CheatsCodeExProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) {
    //Too much code to contain in this post...
}

LRESULT CALLBACK CheatsCodeQuantProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) {
    //code
}

//Because of the inmensity of code, I will skip to the lines that throw errors.

BOOL TreeView_GetCheckState(HWND hwndTreeView, HTREEITEM hItem) { //line 982, error thrown.
    //code here
}

BOOL TreeView_SetCheckState(HWND hwndTreeView, HTREEITEM hItem, BOOL fCheck) //line 999, error thrown
{ //line 1000, error thrown
    //Lots o code
} // line 1013, error thrown

如果需要更多代码,我很乐意发帖!

1 个答案:

答案 0 :(得分:1)

我已经检查了您提供链接的代码。

正确包含

BOOL类型。要检查您是否可以使用Cheat.c选项编译/P

所有问题都是由项目从Visual Studio 6升级到Visual Studio 2015引起的。

如果您要调查预处理器输出,您将看到转换:

BOOL TreeView_GetCheckState(HWND hwndTreeView, HTREEITEM hItem); //(line 55, error thrown.)
BOOL TreeView_SetCheckState(HWND hwndTreeView, HTREEITEM hItem, BOOL fCheck); //(line 56)

预处理到:

BOOL ((((UINT)(SendMessageA((HWND hwndTreeView), (0x1100 + 39), (WPARAM)(HTREEITEM hItem), 0xF000))) >> 12) -1);
BOOL { TVITEMA _ms_TVi; _ms_TVi.mask = 0x0008; _ms_TVi.hItem = (HTREEITEM hItem); _ms_TVi.stateMask = (0xF000); _ms_TVi.state = ((((BOOL fCheck)?2:1) << 12)); SendMessageA((HWND hwndTreeView), (0x1100 + 13), 0, (LPARAM)(TVITEMA *)&_ms_TVi);};

这不是您希望在函数声明中看到的内容。

这两个TreeView_GetCheckStateTreeView_SetCheckState都是CommCtrl.h中定义的标准宏。删除旧功能并使用这些宏。