I want to have global variables which are const, but they should be defined in the mexFunction() function. This is because they should be set to some input values, which come from Matlab. (The mexFunction() is basically my main() function.)
Is something like this even possible?
main.h
extern int const myConstGlobal;
main.c
mexFunction(input)
{
int const myConstGlobal = input;
}
functions.c
#include main.h
foo(myConstGlobal){}
Some links from which I have my current understanding:
How to work with shared global variables is explained in shared-global-variables-in-C.
How to work with shared global const variables is explained in the second answer of this link
...you have to declare:
extern int const const_int ;
in the header, and:
extern int const const_int = fn() ;
in one (and only one) source file.
But like that I need functions to pass the input values which I want to circumvent.