FMOD Result not being recognized as a valid type?
I have following block of code copied almost verbatim out of the fmod tutorials, with a minor modification of variable names so as not to conflict with anything. My code compiles fine without any of the fmod statements. When I put the FMOD_RESULT fm_result
line and all that follows I get an error stating error C4430:开发者_StackOverflow中文版 missing type specifier - int assumed. Note: C++ does not support default-int
I have VS2010, there are no linker or include file errors without the fmod code. The error is regarding the line fm_result = FMOD::System_Create(&fm_system);
I also get the error error C2371: 'fm_result' : redefinition; different basic types
on the same line.
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) %s\n", 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) %s\n", fm_result, FMOD_ErrorString(fm_result));
exit(-1);
}
I don't know, it must be something about Visual Studio, or something else you're not telling us... The following compiles fine with me in 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) %s\n", 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) %s\n", fm_result, FMOD_ErrorString(fm_result));
exit(-1);
}
}
I extracted fmodapi43405linux.tar.gz
into /tmp/
and invoked the compiler like this:
g++ -W -Wall -Wextra -s -O3 -march=native -o prog prog.cpp \
-I /tmp/fmodapi43405linux/api/inc/ \
/tmp/fmodapi43405linux/api/lib/libfmodex.so
It also works if I append -std=c++0x
.
Regarding the error: error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
You would get this if you put FMOD_RESULT blah before your first include of FMOD. Can you make sure that is not the case? Perhaps you have an include chain that is using FMOD_RESULT before including fmod.h.
精彩评论