Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6911085
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:54:24+00:00 2026-05-27T08:54:24+00:00

In my library there’s a class like this: class Foo { public: void doSomething();

  • 0

In my library there’s a class like this:

class Foo {
public:
    void doSomething();
};

Now, implementation of doSomething() has been grow a lot and I want to split it in two methods:

class Foo {
public:
    void doSomething();
private:
    void doSomething1();
    void doSomething2();
};

Where doSomething() implementation is this:

void Foo::doSomething() {
    this->doSomething1();
    this->doSomething2();
}

But now class interface has changed. If I compile this library, all existent applications using this library wont work, external linkage is changed.

How can I avoid breaking of binary compatibility?

I guess inlining solves this problem. Is it right? And is it portable? What happen if compiler optimization uninlines these methods?

class Foo {
public:
    void doSomething();
private:
    inline void doSomething1();
    inline void doSomething2();
};

void Foo::doSomething1() {
    /* some code here */
}

void Foo::doSomething2() {
    /* some code here */
}

void Foo::doSomething() {
    this->doSomething1();
    this->doSomething2();
}

EDIT:
I tested this code before and after method splitting and it seems to maintain binary compatibility. But I’m not sure this would work in every OS and every compiler and with more complex classes (with virtual methods, inheritance…). Sometimes I had binary compatibility breaking after adding private methods like these, but now I don’t remember in which particular situation. Maybe it was due to symbol tabled looked by index (like Steve Jessop notes in his answer).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T08:54:24+00:00Added an answer on May 27, 2026 at 8:54 am

    Strictly speaking, changing the class definition at all (in either of the ways you show) is a violation of the One Definition Rule and leads to undefined behavior.

    In practice, adding non-virtual member functions to a class maintains binary compatibility in every implementation out there, because if it didn’t then you’d lose most of the benefits of dynamic libraries. But the C++ standard doesn’t say much (anything?) about dynamic libraries or binary compatibility, so it doesn’t guarantee what changes you can make.

    So in practice, changing the symbol table doesn’t matter provided that the dynamic linker looks up entries in the symbol table by name. There are more entries in the symbol table than before, but that’s OK because all the old ones still have the same mangled names. It may be that with your implementation, private and/or inline functions (or any functions you specify) aren’t dll-exported, but you don’t need to rely on that.

    I have used one system (Symbian) where entries in the symbol table were not looked up by name, they were looked up by index. On that system, when you added anything to a dynamic library you had to ensure that any new functions were added to the end of the symbol table, which you did by listing the required order in a special config file. You could ensure that binary compatibility wasn’t broken, but it was fairly tedious.

    So, you could check your C++ ABI or compiler/linker documentation to be absolutely sure, or just take my word for it and go ahead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a library out there that has a facility something like: public static
We are using a third part library to render 3d. In this library there
I'm working in a class library and there are other source projects associated with
Is there an open source telnet API/library out there for Java (something like Python
any c/c++ library out there that provides functions like getUrl, urlopen, post etc. ?
In the .NET base class library there is a class System.IO.Path for doing common
Is there an ADSI Library out there for .NET/C#? I have been able to
link text This is a link from a digital book library.There are forward and
I'll keep this short and simple. As part of PHP's mcrypt library there are
Before I get too deep in creating this, is there a library out there

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.