473,714 Members | 3,424 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

__vfptr problem in VC++.NET

Hi All,

I am porting an application from watcom to vc compiler. In watcom and
other compiler (other then vc) memory allocation of __vfptr inside
class object are different. In vc __vfptr is allocated top of the class
object i.e base address of class objects are same as __vfptr address.
But in watcom compiler __vfptr is allocated end of the class object.
Due to this difference, I am getting problem in accessing the member
variable address correctly. Is there any way in vc compiler option to
bring __vfptr from top to bottom of the class object.

Let's take a class example

Class exp_v
{
virtual void foo(void) {};
private:
int a;
int b;
};
In Watcom:-

|-----------------|<-- 0x3660(BaseAddr ess)
|int a |
|-----------------|<-- 0x3664
|int b |
|-----------------|<-- 0x3668
|__vfptr |
|-----------------|
In VC++.NET:-

|-----------------|<-- 0x3660(BaseAddr ess)
|__vfptr |
|-----------------|<-- 0x3664
|int a |
|-----------------|<-- 0x3668
|int b |
|-----------------|
Thanks & Regards
Debadeepti Sahu.

Jul 23 '05 #1
3 4568
BTW this is about VC++7, not .NET, which is a different (slobberin') animal.

debadeepti wrote:
I am porting an application from watcom to vc compiler. In watcom and
other compiler (other then vc) memory allocation of __vfptr inside
class object are different. In vc __vfptr is allocated top of the class
object i.e base address of class objects are same as __vfptr address.
But in watcom compiler __vfptr is allocated end of the class object.
Due to this difference, I am getting problem in accessing the member
variable address correctly. Is there any way in vc compiler option to
bring __vfptr from top to bottom of the class object.
What does "accessing the member variable address" mean? You neglected to
post code to illustrate that.
Class exp_v
{
virtual void foo(void) {};
private:
int a;
int b;
};


If you use the "pointer to member" language feature - which is really a
"smart offset", you shouldn't have trouble. And if you use the 'offsetof()'
macro, you shouldn't either.

But if you somehow stored the byte offset of a member into a data file, and
then need to use that offset after the Replace Compiler Refactor, you will
need to simply encapsulate your discovery of the size and location of the
__vfptr, if any, and live with extra math in your access code, right?

--
Phlip
http://www.c2.com/cgi/wiki?ZeekLand
Jul 23 '05 #2
<de********@ind iatimes.com> wrote in message
news:11******** **************@ g47g2000cwa.goo glegroups.com
Hi All,

I am porting an application from watcom to vc compiler. In watcom and
other compiler (other then vc) memory allocation of __vfptr inside
class object are different. In vc __vfptr is allocated top of the
class object i.e base address of class objects are same as __vfptr
address. But in watcom compiler __vfptr is allocated end of the class
object. Due to this difference, I am getting problem in accessing the
member variable address correctly. Is there any way in vc compiler
option to bring __vfptr from top to bottom of the class object.

Let's take a class example

Class exp_v
{
virtual void foo(void) {};
private:
int a;
int b;
};
In Watcom:-
-----------------|<-- 0x3660(BaseAddr ess)
int a |
-----------------|<-- 0x3664
int b |
-----------------|<-- 0x3668
__vfptr |
-----------------|

In VC++.NET:-
-----------------|<-- 0x3660(BaseAddr ess)
__vfptr |
-----------------|<-- 0x3664
int a |
-----------------|<-- 0x3668
int b |
-----------------|


I believe that the answer to your question is no: you cannot change where
the __vfptr is located. However, the best place to ask is

public.microsof t.vc.language

This is an implementation detail that a programmer normally doesn't need to
know anything about. Writing code that depends on implementation details is
asking for exactly the sort of trouble you are now having. What are you
doing that requires this information?

--
John Carson
Jul 23 '05 #3
de********@indi atimes.com wrote:
Hi All,

I am porting an application from watcom to vc compiler. In watcom and
other compiler (other then vc) memory allocation of __vfptr inside
class object are different. In vc __vfptr is allocated top of the class
object i.e base address of class objects are same as __vfptr address.
But in watcom compiler __vfptr is allocated end of the class object.
Due to this difference, I am getting problem in accessing the member
variable address correctly. Is there any way in vc compiler option to
bring __vfptr from top to bottom of the class object.


I don't think this is possible. But actually, I don't see why you should
ever care where the vtable pointer is. What exactly are you having problems
with?

Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1380
by: R Tamilarasan | last post by:
Curiosity made me to install VC - 7 (.net) in my machine which had VC - 6 already installed. I tried to compile my workspace in VC - 7 but failed due to several compile time errors. ok no problems. So I tried to revert back and uninstalled VC - 7 and compiled my workspace in VC - 6. It gave a linker error that "mfc71d.lib" is not found.
11
1915
by: Tatu Portin | last post by:
Have this kind of struct: typedef struct { char **user_comments; /* ... */ } vorbis_comment; /* prototype */ char * read_vorbis_string ( FILE *sc);
4
2956
by: Anthony Gallagher | last post by:
I have a bunch of libraries compiled using VC++ 6.0, and I am trying to recompile one of our projects using VC++ .NET. I get all kind of linker errors (specially in STL calls). How do I get rid of these errors?? Anthony
0
1520
by: Vijay Chegu | last post by:
Hi I am using vc++ .net 2003 ide with Feb 2003 platform sdk to build 64bit application. I want to use vc++ to debug the app on 64bit machine. As we do not have 64bit VC++, I would like to know how to configure VC++ IDE to do remote debugging. I can install 64bit windbg and do debugging on the local machin, as
5
2345
by: Hari | last post by:
Guys please help me to solve this strange problem what Iam getting as follows.. Trying to instantiate a global instance of a template class as follows :- when i build this code with debug and run this works fine. but if build in unicode release or release this does't work. IS THERE ANY PROBLEM OF INSTANTIATING TEMPLATE CLASSES
2
3121
by: vemulakiran | last post by:
Hi all, I have doubt regarding .NET. I have a tool which was developed on VC++ 6.0(Win32 Application ). The application communicates with library (API) which was developed on VC++ 6.0 called core client. I am planning to develop the tool or Win32 application on .NET platform and I dont' want to migrate the VC++ library (API) to .NET. The new .NET tool should use the previous VC++ library API ( core client ). Is there any possibility to...
2
2285
by: um | last post by:
When the POSIX pthreads library for w32 release 2-2-0 (http://sources.redhat.com/pthreads-win32/) is compiled with VC++6 then it compiles and passes all the benchmark tests in the subdirectory "tests". Also, VC++ 2005 beta 1 compiles the tests fine, but here the following tests fail in execution: # semaphore1.pass \ # condvar2.pass \ # condvar2_1.pass \ # mutex8.pass \
15
2016
by: Michael Tissington | last post by:
I have a Visual Basic 6.0 ActiveX Control. It seems there is no way with VS 2005 to create a similar control for containers that host ActiverX controls, is this correct ? I'm thinking of converting the VB 6 project to VC in VS 2005. This seems to be a very different process. Where is a good place to start?
7
8451
by: Norman Diamond | last post by:
A project depends on VC runtime from Visual Studio 2005 SP1, and DotNet Framework 2. Options are set in the setup project properties, so if these two dependencies are not already installed then this installer will install them. But what about the situation where VC runtime has already been installed? In fact it's been installed twice. Although the project was built on a Windows XP system with Visual Studio 2005 SP1 and the results were...
0
8713
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9318
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9032
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
7957
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
6638
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
5961
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
4467
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...
2
2528
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2113
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.