Solved

MSVC: mixing RTTI and non-RTTI code

Posted on 2001-06-05
5
391 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

627 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