0

Gotta learn FMOD For school project.

In the code (copied from the documentation):

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

What does the second line do (FMOD::System *system;)? What does the next line do (result = FMOD::System_Create(&system);)?

I think the line FMOD::System *system; creates a pointer and the other line creates the system and checks for errors. I just don't get the need for pointers.

Could someone please explain Thank-you

  • You should have documentation included with the SDK. – chris Jan 17 '14 at 23:14
  • @Nabla, Lots of C libraries will work well with `SomeStruct s; Create(&s);` No need for a pointer in your code there. Evidently, this function takes a double pointer, though, and I'm guessing it's an abstract class or something because of that. – chris Jan 17 '14 at 23:18

1 Answers1

0

You first declare a pointer of type FMOD::System* and then the function FMOD::System_Create will populate the pointer with the system object. So, if nothing failed, after the third line system will point to a valid object of type FMOD::System so that you can call system->init few lines below.

Unfortunately the documentation for FMOD is not publicly available so I cannot tell much more. But if you have been given access to it, you should find all the informations you need in there.

Shoe
  • 74,840
  • 36
  • 166
  • 272