Solved

MSVC: mixing RTTI and non-RTTI code

Posted on 2001-06-05
5
385 Views
Last Modified: 2012-05-04
Hi all,
My question is whether it is safe to mix RTTI-enabled and RTTI-disabled. I am asking, because I guess MSVC adds an
extra pointer to vtable structure, so probably it should not be safe, as compiler will not be able to allocate/deallocate memory properly.

If the answer is "NO", then my other questions is: suppose I have third-party library, how do I tell whether it is RTTI-enabled or not.
Finally, if I have two third-party libraries, one is RTTI-enabled and second RTTI-disabled, how can I make them work together in my program.

Thanks
0
Comment
Question by:proskig
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
5 Comments
 
LVL 22

Expert Comment

by:nietod
ID: 6155804
>> My question is whether it is safe to mix RTTI-enabled and RTTI-disabled.
probably not, but I don't know for sure.

>> adds an extra pointer to vtable structure,
many compilers use the first entry in vtable to store a pointer to a structure that has the RTTI info.   But VC has to be COM compatible too.  I don't know if COM woudl require the 1st entry to be a working entry.

This will take a little testing....
0
 
LVL 22

Expert Comment

by:nietod
ID: 6155849
VC uses the same vtable for both cases and the first entry is the pointer to the first virtual function.  There will be no incompatibility there.   its possible that it places the RTTI infor before the table.  I'll look into that.   But it seems like it might be safe as long as you don't actually use RTTI.
0
 
LVL 22

Accepted Solution

by:
nietod earned 200 total points
ID: 6155899
VC seems to be storing something before the start of the table.  its not the RTTI info itself and it is not a pointer to it, but it is definitely accessing the doubleword before the start of the table.    This suggests that it is probaly safe to mix RTTI and non-RTTI, if you really have to.
0
 
LVL 5

Author Comment

by:proskig
ID: 6156034
OK, thanks, it looks the same to me
0
 
LVL 22

Expert Comment

by:nietod
ID: 6156087
That was a guess though...
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to programmatically differentiate between C and Java 10 222
Embarcadero C++ Builder XE2 TDateTime 8 92
Least Squares Curve Fitting 4 134
print bytes of an integer 6 48
In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question