473,795 Members | 2,498 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1021
> 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************* *********@hotma il.com
Remove only "_nos_pam"
Mar 25 '06 #2

"Bruno van Dooren" <br************ **********@hotm ail.com> wrote in message
news:O$******** ********@TK2MSF TNGP09.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
14475
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, Larry Woods
6
11538
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 function directly in the header file, or if the change the function to non-template. For example... *** Why am I getting a link error for template function f() in the code below?
5
562
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 compiler can find the definition of the function prior to encountering the use of the function it will generate the prototype itself. I don't currently use this feature, I explicitly create declarations for all functions in a header file. However, I...
19
2519
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 the declaration for the C library function (stdlib.h in this case) then define/declare my own function with the same name, am I safe? It seems to work on my compiler, but I wonder if this is portable or even acceptable? thx
13
3039
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 the
9
3418
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
3753
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 called in main which is in another .cc file. With g++ compiler, this fails to link.However, it compiles if the template function definitioin also included in header file. Is there a way with g++ to force template function in .cc file?
7
3000
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 various #define(s)
28
8890
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 didn't find any good explanation about it. Could the experts please give me an explanation or point me to some link? Thanks! /Why Tea
0
9672
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10163
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10000
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9040
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7538
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6780
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5436
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.