FMOD结果未被识别为有效类型

FMOD Result not being recognized as a valid type?

本文关键字:有效 类型 识别 结果 FMOD      更新时间:2023-10-16

我几乎逐字逐句地从fmod教程中复制了以下代码块,并对变量名进行了轻微修改,以免与任何内容发生冲突。我的代码在没有任何fmod语句的情况下编译得很好。当我放入FMOD_RESULT fm_result行,然后我得到一个错误,说明error C4430: missing type specifier - int assumed. Note: C++ does not support default-int我有VS2010,如果没有fmod代码,就没有链接器或包含文件错误。错误是关于线fm_result = FMOD::System_Create(&fm_system);,我在同一线上也得到错误error C2371: 'fm_result' : redefinition; different basic types

FMOD_RESULT fm_result;
FMOD::System *fm_system;
fm_result = FMOD::System_Create(&fm_system);        // Create the main system object.
if(fm_result != FMOD_OK){
    printf("FMOD error! (%d) %sn", fm_result, FMOD_ErrorString(fm_result));
    exit(-1);
}
fm_result = fm_system->init(100, FMOD_INIT_NORMAL, 0);  // Initialize FMOD.
if(fm_result != FMOD_OK){
    printf("FMOD error! (%d) %sn", fm_result, FMOD_ErrorString(fm_result));
    exit(-1);
}

我不知道,它一定是关于Visual Studio的东西,或者你没有告诉我们的其他东西…以下内容在GCC 4.6中对我来说很好:

#include <fmod.hpp>
#include <fmod_errors.h>
#include <cstdio>
#include <cstdlib>
int main()
{
  FMOD_RESULT fm_result;
  FMOD::System *fm_system;
  fm_result = FMOD::System_Create(&fm_system);        // Create the main system object.
  if(fm_result != FMOD_OK)
  {
    printf("FMOD error! (%d) %sn", fm_result, FMOD_ErrorString(fm_result));
    exit(-1);
  }
  fm_result = fm_system->init(100, FMOD_INIT_NORMAL, 0);  // Initialize FMOD.
  if(fm_result != FMOD_OK)
  {
    printf("FMOD error! (%d) %sn", fm_result, FMOD_ErrorString(fm_result));
    exit(-1);
  }
}

我将fmodapi43405linux.tar.gz提取到/tmp/中,并调用如下编译器:

g++ -W -Wall -Wextra -s -O3 -march=native -o prog prog.cpp 
    -I /tmp/fmodapi43405linux/api/inc/ 
    /tmp/fmodapi43405linux/api/lib/libfmodex.so

如果我附加-std=c++0x,它也会起作用。

关于错误:错误C4430:缺少类型说明符-假定为int。注意:C++不支持默认的int

如果你在第一次包含FMOD之前放上FMOD_RESULT等等,你就会得到这个。你能确定不是这样吗?也许您有一个包含链,在包含FMOD.h之前使用FMOD_RESULT。