Policies/Binary Compatibility Examples: Difference between revisions
(Undo revision 43255: oops, this example was already there) |
(Add a section on changing CV qualifiers of data) |
||
Line 232: | Line 232: | ||
|} | |} | ||
== Change the CV-qualifiers == | == Change the CV-qualifiers of a member function == | ||
{| | {| | ||
|- | |- | ||
Line 250: | Line 250: | ||
public: | public: | ||
int something(); | int something(); | ||
}; | |||
</code> | |||
|} | |||
== Change the CV-qualifiers of global data == | |||
{| | |||
|- | |||
! Before | |||
! After | |||
|- | |||
| <code cppqt> | |||
// MSVC mangling: ?data@@3HA | |||
int data = 42; | |||
</code> | |||
| <code cppqt> | |||
// MSVC mangling: ?data@@3HB | |||
const int data = 42; | |||
</code> | |||
|- | |||
| <code cppqt> | |||
class MyClass | |||
{ | |||
public: | |||
// MSVC mangling: ?data@MyClass@@2HA | |||
static int data; | |||
}; | |||
</code> | |||
| <code cppqt> | |||
class MyClass | |||
{ | |||
public: | |||
// MSVC mangling: ?data@MyClass@@2HB | |||
static const int data; | |||
}; | |||
</code> | |||
|- | |||
| <code cppqt> | |||
class MyClass | |||
{ | |||
public: | |||
static int data; | |||
}; | |||
</code> | |||
| <code cppqt> | |||
class MyClass | |||
{ | |||
public: | |||
// the compiler won't even create a symbol | |||
static const int data = 42; | |||
}; | }; | ||
</code> | </code> |
Revision as of 08:28, 15 July 2009
This page is meant as examples of things you cannot do in C++ when maintaining binary compatibility.
Unexport or remove a class
Before | After |
---|---|
|
|
Change the class hierarchy
Before | After |
---|---|
|
|
|
|
Change the template arguments of a template class
Before | After |
---|---|
|
|
Unexport a function
Before | After |
---|---|
|
|
|
|
Inline a function
Before | After |
---|---|
|
|
|
|
|
|
|
|
Change the parameters of a function
Before | After |
---|---|
|
|
|
|
|
|
|
|
Change the return type
Before | After |
---|---|
|
|
Change the access rights
Before | After |
---|---|
|
|
Change the CV-qualifiers of a member function
Before | After |
---|---|
|
|
Change the CV-qualifiers of global data
Before | After |
---|---|
|
|
|
|
|
|
Add a virtual member function to a class without any
Before | After |
---|---|
|
|
Add new virtuals to a non-leaf class
Before | After |
---|---|
|
|
Change the order of the declaration of virtual functions
Before | After |
---|---|
|
|
Override a virtual that doesn't come from a primary base
class PrimaryBase
{
public:
virtual ~PrimaryBase();
virtual void foo();
};
class SecondaryBase
{
public:
virtual ~PrimaryBase();
virtual void bar();
};
Before | After |
---|---|
|
|
Override a virtual with a covariant return with different top address
struct Data1 { int i; };
class BaseClass
{
public:
virtual Data1 *get();
};
struct Data0 { int i; };
struct Complex1: Data0, Data1 { };
struct Complex2: virtual Data1 { };
Before | After |
---|---|
|
|
|
|