Skip to content

Compilation failure on Linux (GCC): 'expected initializer before' error with F_CALLBACK in sound_game.cpp #971

Description

@00ein00

Environment:

  • OS: Arch Linux
  • Compiler: GCC (cc1plus)
  • Build System: CMake / Make

When attempting to compile Barony from source, the build fails at src/engine/audio/sound_game.cpp due to syntax errors surrounding the F_CALLBACK macro. The compiler does not recognize or properly handle the macro for several FMOD callback functions, resulting in an expected initializer before error and subsequent "not declared in this scope" failures.

To Reproduce

  1. Clone the repository on a modern Linux system
  2. Configure the build using CMake with FMOD enabled (-DFMOD_ENABLED=ON).
  3. Run make.
  4. The build fails when compiling sound_game.cpp.

Error Log Snippet

/src/engine/audio/sound_game.cpp:3247:24: error: expected initializer before ‘ensembleExplorationCallback’
 3247 | FMOD_RESULT F_CALLBACK ensembleExplorationCallback(FMOD_CHANNELCONTROL* channelcontrol,
      |                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/src/engine/audio/sound_game.cpp:3253:24: error: expected initializer before ‘ensembleCombatCallback’
 3253 | FMOD_RESULT F_CALLBACK ensembleCombatCallback(FMOD_CHANNELCONTROL* channelcontrol,
      |                        ^~~~~~~~~~~~~~~~~~~~~~
/src/engine/audio/sound_game.cpp: In member function ‘void EnsembleSounds_t::playSong()’:
/src/engine/audio/sound_game.cpp:3276:62: error: ‘ensembleExplorationCallback’ was not declared in this scope

(Note: A similar error also occurs earlier in the file for pcmreadcallback around line 1223).

Suggested Fix

The F_CALLBACK calling convention macro is causing GCC to choke on Linux. Removing F_CALLBACK from both the forward declarations and function definitions resolves the issue and allows the compilation to finish successfully.

The following functions need to be updated in src/engine/audio/sound_game.cpp:

1. pcmreadcallback (around line 1223)

// Change from:
FMOD_RESULT F_CALLBACK pcmreadcallback(FMOD_SOUND* sound, void* data, unsigned int datalen)
// To:
FMOD_RESULT pcmreadcallback(FMOD_SOUND* sound, void* data, unsigned int datalen)

2. ensembleExplorationCallback (around lines 3247 and 4028)

// Change from:
FMOD_RESULT F_CALLBACK ensembleExplorationCallback(FMOD_CHANNELCONTROL* channelcontrol, ...
// To:
FMOD_RESULT ensembleExplorationCallback(FMOD_CHANNELCONTROL* channelcontrol, ...

3. ensembleCombatCallback (around lines 3253 and 3789)

// Change from:
FMOD_RESULT F_CALLBACK ensembleCombatCallback(FMOD_CHANNELCONTROL* channelcontrol, ...
// To:
FMOD_RESULT ensembleCombatCallback(FMOD_CHANNELCONTROL* channelcontrol, ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions