[英]Syntax error compiling header containing “char[]”
I am trying to build a Visual C++ 2008 DLL using SDL_Mixer 1.2: 我正在尝试使用SDL_Mixer 1.2构建Visual C ++ 2008 DLL:
http://www.libsdl.org/projects/SDL_mixer/ http://www.libsdl.org/projects/SDL_mixer/
This is supposedly from a build made for Visual C++, but when I include SDL_mixer.h I get error C2143 : " syntax error : missing ';' 据说这是为Visual C ++构建的,但是当我包含SDL_mixer.h时,出现错误C2143 :“ 语法错误:缺少';' before '[' ".
在“ [”之前 。
The problem line is: 问题行是:
const char[] MIX_EFFECTSMAXSPEED = "MIX_EFFECTSMAXSPEED"; const char [] MIX_EFFECTSMAXSPEED =“ MIX_EFFECTSMAXSPEED”;
Is this because of the use of the dynamic array construct "char[]", instead of "char*"? 这是因为使用了动态数组构造“ char []”而不是“ char *”吗?
All the expressions in the file are wrapped by " extern "C" {
". 文件中的所有表达式都由“
extern "C" {
“包裹。
在变量名称后移动方括号
const char MIX_EFFECTSMAXSPEED[] = "MIX_EFFECTSMAXSPEED";
You want: 你要:
const char MIX_EFFECTSMAXSPEED[] = "MIX_EFFECTSMAXSPEED";
Note that there is no "dynamic array construct" here - you have an array of char that is initialised witha string literal - all compile time things. 请注意,这里没有“动态数组构造”-您有一个用字符串文字初始化的char数组-所有编译时都是如此。
My bad. 我的错。 Although the answers here are correct regarding C construct, the actual problem was that I had included a "D" language file instead of the C version.
尽管这里的答案对于C构造是正确的,但实际的问题是我包括了“ D”语言文件而不是C版本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.