I have a C++ framework where some calculations are delegated to (sometimes auto generated) C functions or C++ functions with external "C" linkage. These are low-level routines that must be evaluated very fast and with minimal overhead and they typically reside in separate shared objects/DLLs. Their current signature is something along the lines of:
int my_generated_function(const double* input, double* output, double* work);
which will reside in a shared library loaded using dlopen
on POSIX or LoadLibrary
on Windows. The corresponding function pointers are extracted using dlsym(handle, "my_generated_function")
on POSIX or GetProcAddress(handle, TEXT("my_generated_function"))
on Windows.
Is it safe and portable to augment the signature with a FILE object pointer?
int my_generated_function(const double* input, double* output, double* work,
FILE* logfile);
Note that the shared object containing my_generated_function
might have been compiled with a different (but binary compatible) compiler than the code that loads the shared object.