B
Bryan Parkoff
I have written over 4096 functions for my project. I would like to
create one Function Pointer so Function Pointer will contain 4096 functions.
I do not want Function Pointer to be stored in the static memory so I am
trying to think how to tell Function Pointer to be stored in the dyramic
memory. The problem is that C/C++ Compiler can't handle source code more
than 64K limit so it has to create smaller sub-source codes to avoid 64K
limit. After linking, all sub-source codes will be together into one
executable file.
Static memory will not fit in one source code because of 64K limit.
Dyramic memory is only the option. Look at my example below.
unsigned int* pFunc = new unsigned int[4096];
void (*p_Func[4096])(void);
p_Func = pFunc;
p_Func[0] = Func0;
p_Func[1] = Func1;
p_Func[2] = Func2;
...
...
...
p_Func[4094] = Func4094;
p_Func[4095] = Func4095;
p_Func[4096] = Func4096;
You may notice strange because "void (*p_Func[4096])(void) = new void
(*p_Func)(void)" do not work because Function Pointer can't use new keyword.
There may be another way. "unsigned int* pFunc = new unsigned int[4096];"
has to be done first to create dyramic memory. Then "p_Func = pFunc;" is to
copy memory address from pFunc to p_Func before I can be able to add
thousand functions to p_Func that is linked to pFunc.
I do not intend to declare and define "void (*p_Func[...])(void) = {
...., ..., ... } because it is only constant because of source code 64K
limit. I intend to modify function names in the Function Pointer listing.
Do you know what I mean?
Maybe reinterpret_cast may be the option, but it has to find other way
how to declare and define Function Pointer using new keyword. Please
advise. Thanks...
Bryan Parkoff
create one Function Pointer so Function Pointer will contain 4096 functions.
I do not want Function Pointer to be stored in the static memory so I am
trying to think how to tell Function Pointer to be stored in the dyramic
memory. The problem is that C/C++ Compiler can't handle source code more
than 64K limit so it has to create smaller sub-source codes to avoid 64K
limit. After linking, all sub-source codes will be together into one
executable file.
Static memory will not fit in one source code because of 64K limit.
Dyramic memory is only the option. Look at my example below.
unsigned int* pFunc = new unsigned int[4096];
void (*p_Func[4096])(void);
p_Func = pFunc;
p_Func[0] = Func0;
p_Func[1] = Func1;
p_Func[2] = Func2;
...
...
...
p_Func[4094] = Func4094;
p_Func[4095] = Func4095;
p_Func[4096] = Func4096;
You may notice strange because "void (*p_Func[4096])(void) = new void
(*p_Func)(void)" do not work because Function Pointer can't use new keyword.
There may be another way. "unsigned int* pFunc = new unsigned int[4096];"
has to be done first to create dyramic memory. Then "p_Func = pFunc;" is to
copy memory address from pFunc to p_Func before I can be able to add
thousand functions to p_Func that is linked to pFunc.
I do not intend to declare and define "void (*p_Func[...])(void) = {
...., ..., ... } because it is only constant because of source code 64K
limit. I intend to modify function names in the Function Pointer listing.
Do you know what I mean?
Maybe reinterpret_cast may be the option, but it has to find other way
how to declare and define Function Pointer using new keyword. Please
advise. Thanks...
Bryan Parkoff