473,396 Members | 2,039 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

replace a VC function or a definition from a header

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
2 1003
> 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

"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Larry Woods | last post by:
I have a "homegrown" dll that I am using in IIS (VBScript). I need to replace it on a production server, but I don't want to stop/restart server in order to replace the dll. Possible? TIA,...
6
by: Suzanne | last post by:
Hi++, I get a link error when I try to call a template function that is declared in a header file and defined in a non-header file. I do *not* get this link error if I define the template...
5
by: Daniel Nichols | last post by:
I've noticed that in a C module (.c, .h file combination) that if you create a function's definition before it is used in other functions than a declaration is not necessary. I believe if the...
19
by: Deniz Bahar | last post by:
Hi, I would like to call one of my functions the exact name as an existing C library function (for example K&R2 exercises asks me to make an atof function). If I don't include the header with...
13
by: Old Wolf | last post by:
I have some code that has in the header file: void foo( char bar ); and in the source file: void foo( bar ) char bar; { /* etc. */ } The compiler (with many warnings enabled) warns that...
9
by: lucifer | last post by:
Hi I have a little problem regarding inline functions ,does declaring a function inside the class definition make it inline or not.
5
by: aryan | last post by:
Is it not allowed to have template function definition in a .cc file? Here is the scenario. The tempage function declaration is in a header file and the definition in a .cc file. The function is...
7
by: bcpkh | last post by:
Hello All Received a header file from a supplier that defines an interface to implement but it's giving me a problem, I reproduce the general structure of the header file below; #ifndef XYZ_H...
28
by: Why Tea | last post by:
I seem to remember that in ANSI C, all static functions should have their function prototypes listed at the beginning of the file for better consistency (or something like that). I googled and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.