On 8/7/06, Thomas Voth <[EMAIL PROTECTED]> wrote:

Has anyone been able to override a C library function?  The code I'm working with is based in C and needs to compile with both the default Visual Studio Compiler and GCC so I don't believe LD_PRELOAD will work in this case (which is what I turn up when searching Google).

 

The goal behind this question is to build a shared library of common code for our BREW (Qualcomm's Binary Runtime Environment for Wireless) applications.   I'm trying to override library functions is because the BREW implementations on different handsets to be "touchy" and each handset has its own set of issues that can prevent code (that works on all the other handsets) from running.   This isn't a big deal with porting to 5 or 6 handsets, but when we port to all handsets (usually 40 to 50 handsets) accounting for all of these issues makes the code exceptionally messy.



Create wrappers for the usual C functions with the bodies optionally compilable/executable?

FILE* BREW_fopen(const char* filename, const char* mode){
#ifdef HANDSET1
   // do stuff specific to handset 1
#elseif HANDSET2
   //...
#else
   return fopen(filename, mode);
#endif
}

Then use your wrapper functions where you'd normally call the system functions

P.S.  The BREW architect at my company did suggest writing a custom vtable to help redirect functions from the standard set when needed and I might be able to sell for latter applications, but the current stance on this is that it would require too much rewriting of the current code.

To use vtables sensibly it'd have to be re-written in C++.

--
PJH

Into motorcycles? Need parts? Try www.gissit.com to contact lots of motorcycle breakers - free to use (UK based at the moment) __._,_.___

To unsubscribe, send a blank message to <mailto:[EMAIL PROTECTED]>.




SPONSORED LINKS
C programming language Programming languages Computer programming languages
Java programming language


YAHOO! GROUPS LINKS




__,_._,___

Reply via email to