replace a VC function or a definition from a header

  • Thread starter Thread starter Egbert Nierop
  • Start date Start date
E

Egbert Nierop

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,
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
(e-mail address removed)
Remove only "_nos_pam"
 
Bruno van Dooren said:
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 :)
 
Back
Top