![]() |
Is it possible?
Well, i'm busy with a secret project.
The question is, can i have something like: file a.cpp Code:
int ReturnSomeIndex() Code:
int UTIL_ReturnSomeIndex() file B must be in the project all the time, but will work even without file A. So when ReturnSomeIndex() does not exist, it compiles fine. I thought there was something done like this in botmans code before, with the engine functions put in a void *. But i am not sur eif this is possible. So i want to override the UTIL_ReturnSomeIndex() with resulting a function. But even if that function does not exist (for neatness sake). I know i can 'do this simpler' with a simple boolean value or something like that. Or even provide an empty ReturnSomeIndex() function in file A. But thats the key, file A should NOT be needed and still compile and the program should run... any idea? |
Re: Is it possible?
The only way to do this is to set up a table of function pointers (like the g_engfuncs we all know in HL1). Else your linker will complain about undefined identifiers.
|
Re: Is it possible?
i was afraid of that ;)
|
Re: Is it possible?
yes, I think the only way would be to use function pointer tables and some sort of loading routines, like .dll / .so loading
|
Re: Is it possible?
Yeah I have no idea how to do this. You will most likely need to make a library and use a header file. Like this:
Code:
extern int ReturnSomeIndex(); http://www.function-pointer.org/ BTW, pfn stands for pointer to function. That is how you can denote it. |
Re: Is it possible?
I thought of this method, but in fact this caused double-trouble. I might go this route again, but i don't think its worth it and can be done easier. Though, i'm still interested in this, its similiar how the Think functions work in HL2... they do a "SetTHink" or something ;) But thats something you guys already knew of course.
|
All times are GMT +2. The time now is 20:48. |
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.