• Runtimes
  • Compilation Errors on DirectX 11 from class SpineExtension

Hi,
I'm encountering compilation errors when integrating the Spine C++ runtime into my custom game engine, which is built on DirectX 11 (D3D11). The errors occur in member functions from the SpineExtension class (SpineExtension::calloc, SpineExtension::realloc, etc.), all related to memory allocation.

Issue Details:

Error Count: 72 compilation errors consistently occur.

Affected Files:

Extension.h
SpineSpring.h
Vector.h
BlockAllocator.h
Pool.h

Functions Causing Errors:

from **class SpineExtension** in **Extension.h**
static T *alloc(size_t num, const char *file, int line);
static T *calloc(size_t num, const char *file, int line);
static T *realloc(T *ptr, size_t num, const char *file, int line);
static void free(T *ptr, const char *file, int line);

Error Logs (Duplicated logs omitted)

unrecognizable template declaration/definition
type 'char' unexpected
syntax error: unexpected token '>' following 'simple-type-specifier'

syntax error: unexpected token '>' following 'simple-declaration'
syntax error: unexpected token '>' following 'expression'

syntax error: unexpected token ',' following 'expression-statement'

syntax error: unexpected token ')' following 'statement-seq'
syntax error: unexpected token ')' following 'statement'
syntax error: unexpected token ')' following 'selection-statement'
syntax error: unexpected token ')' following 'expression-statement'
syntax error: unexpected token ')' following 'compound-statement'
syntax error: missing ')' before ','
syntax error: 'constant'
syntax error: ',' was unexpected here; expected ';'
syntax error: ','
syntax error: ')' was unexpected here; expected '}'
syntax error: ')' was unexpected here; expected ';'
syntax error: ')'
'valueCopy': undeclared identifier
'spine::SpineExtension::_realloc_dbg': no matching overloaded function found
'spine::SpineExtension::_free_dbg': no matching overloaded function found

'line': undeclared identifier
'file': undeclared identifier
'file': identifier not found
'calloc': is not a member of 'spine::SpineExtension'

What I’ve Checked:

My game engine code doesn’t seem to have any issues, so I suspect something might be missing in my Spine integration. However, I’m not sure what the missing piece could be.
Any insights or suggestions on what might be causing this would be greatly appreciated. Please let me know if you need any additional details.

Thank you!

Related Discussions
...

The errors you're encountering when integrating the Spine C++ runtime into your DirectX 11 engine seem to be related to the implementation of the SpineExtension class, particularly with memory allocation functions. The SpineExtension class is designed to allow custom memory management by overriding functions like alloc, calloc, realloc, and free. These functions are expected to be implemented in a way that suits your engine's memory management strategy.

To resolve these errors, ensure that you have correctly implemented a custom SpineExtension class. This class should derive from DefaultSpineExtension and override the necessary memory management functions. You can then set your custom extension using spine::SpineExtension::setInstance() at the start of your program. If you are not using the default memory management, you need to implement the spine::getDefaultExtension() function to return your custom extension.

Additionally, check for any macros or preprocessor directives in your engine that might conflict with the Spine runtime, as these could cause unexpected syntax errors. Ensure that your custom SpineExtension implementation is correctly included and linked in your project.

If you are using the DebugExtension for memory leak detection, make sure it is correctly wrapped around your custom extension. This can help identify any memory management issues during runtime.

Please don't omit file names and line numbers. It's impossible to say what might go on.

Do you have any way for us to reproduce this? What Godot version are you using? E.g. the specific commit or branch or tag.

Our C++ sources use bog standard C++11 and work with all major compilers (MSVC, Clang, GCC) from the past 7 years.

  • JBPark1654 ответили на это сообщение.
    9 дней спустя

    Mario
    Hi. Sorry that I didn't provide the required info.
    I tried to identify the problem for a week but couldn't find the solution.

    The error occurs at the Extension.h, Line 52 of the Spine C++ Runtime, and
    Extension.h(52,13): error C2988: unrecognizable template declaration/definition
    is the first error message that probably triggers all the following errors.

    I imported code to the Visual Studio project and added the "getDefaultExtension()" extern function.
    Following the example code from the documentation, however, the errors popped up.

    One thing suspicious is that I'm working on a Visual Studio Solution with 2 project files - "Editor" and "Engine". The "Editor" depends on the "Engine", hence the latter is built first into a .lib file then "Editor" reads it. The spine runtime headers and .cpps are included in the "Engine". But the error occurs from building the "Editor". (As shown in the image below)

    I hope these will help identify the problem. If there's anything I can help, please let me know.
    Thanks!

    The error says line number 52, char position 13. That line ends at position 10 in the current 4.2 branch.

    What version of spine-cpp are you using? Is there any way you could provide a minimal project that reproduces the issue?

    • JBPark1654 ответили на это сообщение.

      Mario
      Hi, thank you for the suggestion.

      I built a minimal project to isolate the issue and confirmed that the problem was neither with the runtime nor the import process into the engine. It turned out to be a minor reference error in a small part of the code in the engine. (Presumely it produced more problems when used with Jumbo Build in Visual Studio) After resolving the problem I was able to successfully import, build the runtime, and obtain the expected output.

      I appreciate your assistance!

      Glad you made it work!