472,331 Members | 1,823 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

__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(BaseAddress)
|int a |
|-----------------|<-- 0x3664
|int b |
|-----------------|<-- 0x3668
|__vfptr |
|-----------------|
In VC++.NET:-

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

Jul 23 '05 #1
3 4501
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********@indiatimes.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.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(BaseAddress)
int a |
-----------------|<-- 0x3664
int b |
-----------------|<-- 0x3668
__vfptr |
-----------------|

In VC++.NET:-
-----------------|<-- 0x3660(BaseAddress)
__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.microsoft.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********@indiatimes.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
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...
11
by: Tatu Portin | last post by:
Have this kind of struct: typedef struct { char **user_comments; /* ... */ } vorbis_comment; /* prototype */ char * read_vorbis_string (...
4
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...
0
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....
5
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...
2
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...
2
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...
15
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...
7
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...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: CD Tom | last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...

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.