Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / March 2006

Tip: Looking for answers? Try searching our database.

replace a VC function or a definition from a header

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Egbert Nierop - 24 Mar 2006 18:19 GMT
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.
Bruno van Dooren - 25 Mar 2006 10:22 GMT
> Hi,
>
[quoted text clipped - 3 lines]
> 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.

Signature

Kind regards,
   Bruno van Dooren
   bruno_nos_pam_van_dooren@hotmail.com
   Remove only "_nos_pam"

Egbert Nierop (MVP for IIS) - 25 Mar 2006 23:32 GMT
>> Hi,
>>
[quoted text clipped - 30 lines]
> 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 :)

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.