By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,963 Members | 1,588 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,963 IT Pros & Developers. It's quick & easy.

replace a VC function or a definition from a header

P: n/a
Hi,

Is it possible to redirect the linker & compiler to use a similar function
without getting complaints about 'function x already in blah.obj'?

Of course, I'm not talking about a runtime hook but about compilation time.

Mar 24 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
> Hi,

Is it possible to redirect the linker & compiler to use a similar function
without getting complaints about 'function x already in blah.obj'?

Of course, I'm not talking about a runtime hook but about compilation
time.


Hi,

There is /FORCE:MULTIPLE, but that will still give you linker warnings.

There is a simple trick however.
Sometime ago I had to port an ANSI CPP program from linux to windows.
Apart from a few pitfalls, it all went right, but I had to change a few
functions that had to do with
file path parsing (\ instead of / etc)

In order to avoid modifying the original source, I added a header and source
file to the project with my own
implementation of those files. I added the headers of the original source
file to my own header, and after those headers I added the following macro:
#define old_function new_function

where old function was the function originally called in the original
sources. new_function was my implementation.

the last thing was to 'Force include' my header file into the original
source file via a compiler option.

As a result of this, the preprocessor replaced all old_function calls with
new_function calls without modifying
a single line in the original source file.

--

Kind regards,
Bruno van Dooren
br**********************@hotmail.com
Remove only "_nos_pam"
Mar 25 '06 #2

P: n/a

"Bruno van Dooren" <br**********************@hotmail.com> wrote in message
news:O$****************@TK2MSFTNGP09.phx.gbl...
Hi,

Is it possible to redirect the linker & compiler to use a similar
function without getting complaints about 'function x already in
blah.obj'?

Of course, I'm not talking about a runtime hook but about compilation
time.


Hi,> There is /FORCE:MULTIPLE, but that will still give you linker
warnings.

There is a simple trick however.
Sometime ago I had to port an ANSI CPP program from linux to windows.
Apart from a few pitfalls, it all went right, but I had to change a few
functions that had to do with
file path parsing (\ instead of / etc)

In order to avoid modifying the original source, I added a header and
source file to the project with my own
implementation of those files. I added the headers of the original source
file to my own header, and after those headers I added the following
macro:
#define old_function new_function

where old function was the function originally called in the original
sources. new_function was my implementation.

the last thing was to 'Force include' my header file into the original
source file via a compiler option.

As a result of this, the preprocessor replaced all old_function calls with
new_function calls without modifying
a single line in the original source file.


Ok so this is the definite work-around. It makes me feel uncomfortable to
copy-paste the whole oleaut.h (for instance) into my own header :<
I think, I'll stick with duplicate classes at runtime, below the custom
include, my replacement 'works' and before it, the original one :)

Mar 25 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.