gpt4 book ai didi

c++ - '字' : 'char [20]' differs in levels of indirection from 'unsigned short'

转载 作者:行者123 更新时间:2023-11-30 03:34:45 26 4
gpt4 key购买 nike

我是 c++ 的新手,我收到了一个我想要运行的数据分析程序。我基本上只有一个错误要解决(在消除了数百个错误之后),但我似乎无法破解这个错误的含义。这段代码在 Mac 上运行得很好,但我的是 Windows。我也在使用 Visual Studio。

这是发生错误的脚本。错误出现在以下行:

typedef char WORD[NWORD];

/***********************************************

Header file with generally useful Macros

Version for C++

As written here, can be included "indescriminantly"
without danger of multiple definitions. Nothing will
be inserted if content has already been included.

Program must also include stdio.h and stdlib.h, but these
are almost universal.

*********************************************************/

#ifndef MCRO

#define MCRO

#define PI 3.14159265358979

#define AND &&
#define OR ||
#define IS ==

#include <cstring>


#define STRCHK(x,y) if(strlen(x) >= (y)) {printf("String %s too long\n",x);exit(0);}

// This is a macro for checking reads for overrunning memory allocation
// It is a function void STRCHK( char* x, int y) that quits program if
// string is filled beyond its capacity y.
// NOTE: No ';' is needed to end line with this Macro.


#define SKIPLINE(x) fscanf(x,"%*s%*[^\n\r][\n\r]")
// This macro skips a line in reading the file (pointer) x
// It works regardless of whether \n or\r is used for new lines

#define NWORD 20
#define NPHRASE 200

typedef char WORD[NWORD]; // Utilities for construction of arrays of strings
typedef char PHRASE[NPHRASE];

#endif

最佳答案

在 Windows 上,符号“WORD”由埋藏在 中的#define 定义[不好的做法,但历史需要向前兼容,对吧]

您需要使用除“WORD”之外的其他内容来进行您自己的定义。

Microsoft Page将向您展示其他一些危险符号。

关于c++ - '字' : 'char [20]' differs in levels of indirection from 'unsigned short' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41837421/

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