﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
5152	FMI fmi2CallbackFunctions is incompatible with C++	federico.terraneo@…	Lennart Ochel	"OpenModelica when exporting FMU produces a fmi2FunctionTypes.h
with the following code

typedef struct {
   const fmi2CallbackLogger         logger;
   const fmi2CallbackAllocateMemory allocateMemory;
   const fmi2CallbackFreeMemory     freeMemory;
   const fmi2StepFinished           stepFinished;
   const fmi2ComponentEnvironment   componentEnvironment;
} fmi2CallbackFunctions;

where all fields are declared const. However in C++ const fields in structs/classes can only be initialized in a constructor's intialization list, and the struct has no constructor. I think const should be removed to make this code interoperable with C++.

This is what g++ produces:

fmitest.cpp: In function ‘int main()’:
fmitest.cpp:14:27: error: use of deleted function ‘fmi2CallbackFunctions::fmi2CallbackFunctions()’
     fmi2CallbackFunctions callbacks;
                           ^~~~~~~~~
In file included from FmiTest.Model/sources/include/fmi2/fmi2Functions.h:148:0,
                 from fmitest.cpp:8:
FmiTest.Model/sources/include/fmi2/fmi2FunctionTypes.h:135:3: note: ‘fmi2CallbackFunctions::fmi2CallbackFunctions()’ is implicitly deleted because the default definition would be ill-formed:
 } fmi2CallbackFunctions;
   ^~~~~~~~~~~~~~~~~~~~~
FmiTest.Model/sources/include/fmi2/fmi2FunctionTypes.h:135:3: error: uninitialized const member in ‘struct fmi2CallbackFunctions’
FmiTest.Model/sources/include/fmi2/fmi2FunctionTypes.h:130:37: note: ‘void (* const fmi2CallbackFunctions::logger)(fmi2ComponentEnvironment, fmi2String, fmi2Status, fmi2String, fmi2String, ...)’ should be initialized
    const fmi2CallbackLogger         logger;
                                     ^~~~~~
FmiTest.Model/sources/include/fmi2/fmi2FunctionTypes.h:135:3: error: uninitialized const member in ‘struct fmi2CallbackFunctions’
 } fmi2CallbackFunctions;
   ^~~~~~~~~~~~~~~~~~~~~
FmiTest.Model/sources/include/fmi2/fmi2FunctionTypes.h:131:37: note: ‘void* (* const fmi2CallbackFunctions::allocateMemory)(size_t, size_t)’ should be initialized
    const fmi2CallbackAllocateMemory allocateMemory;
                                     ^~~~~~~~~~~~~~
FmiTest.Model/sources/include/fmi2/fmi2FunctionTypes.h:135:3: error: uninitialized const member in ‘struct fmi2CallbackFunctions’
 } fmi2CallbackFunctions;
   ^~~~~~~~~~~~~~~~~~~~~
FmiTest.Model/sources/include/fmi2/fmi2FunctionTypes.h:132:37: note: ‘void (* const fmi2CallbackFunctions::freeMemory)(void*)’ should be initialized
    const fmi2CallbackFreeMemory     freeMemory;
                                     ^~~~~~~~~~
FmiTest.Model/sources/include/fmi2/fmi2FunctionTypes.h:135:3: error: uninitialized const member in ‘struct fmi2CallbackFunctions’
 } fmi2CallbackFunctions;
   ^~~~~~~~~~~~~~~~~~~~~
FmiTest.Model/sources/include/fmi2/fmi2FunctionTypes.h:133:37: note: ‘void (* const fmi2CallbackFunctions::stepFinished)(fmi2ComponentEnvironment, fmi2Status)’ should be initialized
    const fmi2StepFinished           stepFinished;
                                     ^~~~~~~~~~~~
FmiTest.Model/sources/include/fmi2/fmi2FunctionTypes.h:135:3: error: uninitialized const member in ‘struct fmi2CallbackFunctions’
 } fmi2CallbackFunctions;
   ^~~~~~~~~~~~~~~~~~~~~
FmiTest.Model/sources/include/fmi2/fmi2FunctionTypes.h:134:37: note: ‘void* const fmi2CallbackFunctions::componentEnvironment’ should be initialized
    const fmi2ComponentEnvironment   componentEnvironment;
"	defect	closed	high	Future	FMI	v1.13.0-dev-nightly	fixed		
