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 6858099
In Process

The Archive Base Latest Questions

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

I know adding static member function is fine, but how about an enum definition?

  • 0

I know adding static member function is fine, but how about an enum definition? No new data members, just it’s definition.


A little background:

I need to add a static member function (in a class), that will recognize (the function) the version of an IP address by its string representation. The first thing, that comes to my mind is to declare a enum for IPv4, IPv6 and Unknown and make this enum return code of my function.

But I don’t want to break the binary backward compatibility.

And a really bad question (for SO) – is there any source or question here, I can read more about that? I mean – what breaks the binary compatibility and what – does not. Or it depends on many things (like architecture, OS, compiler..)?


EDIT: Regarding the @PeteKirkham ‘s comment: Okay then, at least – is there a way to test/check for changed ABI or it’s better to post new question about that?

EDIT2: I just found a SO Question : Static analysis tool to detect ABI breaks in C++ . I think it’s somehow related here and answers the part about tool to check binary compatibility. That’s why I relate it here.

  • 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-27T02:06:55+00:00Added an answer on May 27, 2026 at 2:06 am

    The real question here, is obviously WHY make it a class (static) member ?

    It seems obvious from the definition that this could perfectly be a free function in its own namespace (and probably header file) or if the use is isolated define in an anonymous namespace within the source file.

    Although this could still potentially break ABI, it would really take a funny compiler to do so.

    As for ABI breakage:

    • modifying the size of a class: adding data members, unless you manage to stash them into previously unused padding (compiler specific, of course)
    • modifying the alignment of a class: changing data members, there are tricks to artificially inflate the alignment (union) but deflating it requires compiler specific pragmas or attributes and compliant hardware
    • modifying the layout of a vtable: adding a virtual method may change the offsets of previous virtual methods in the vtable. For gcc, the vtable is layed out in the order of declaration, so adding the virtual method at the end works… however it does not work in base classes as vtable layout may be shared with derived classes. Best considered frozen
    • modyfing the signature of a function: the name of the symbol usually depends both on the name of the function itself and the types of its arguments (plus for methods the name of the class and the qualifiers of the method). You can add a top-level const on an argument, it’s ignored anyway, and you can normally change the return type (this might entails other problems though). Note that adding a parameter with a default value does break the ABI, defaults are ignored as far as signatures are concerned. Best considered frozen
    • removing any function or class that previously exported symbols (ie, classes with direct or inherited virtual methods)

    I may have forgotten one or two points, but that should get you going for a while already.

    Example of what an ABI is: the Itanium ABI.

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

Sidebar

Related Questions

I know ant-contrib has a for loop, but I'd rather avoid adding it to
I am trying to write a static function to Or two expressions, but recieve
I'm adding some .cshtml files with some content (nothing dynamicaly loaded, just a static
Whenever I open a Bash shell, my classpath is someProgram. I know that adding
Does anyone know what the difference is between adding an appropriate JAR-file (eg. Apache
Do you know any bug tracking tools that support adding bugs by sending an
does anyone know how you edit/maintain regions in magento - specifically adding ones for
Does anyone know what the esiest way to update the entity model after adding/deleting
Know this might be rather basic, but I been trying to figure out how
I've got an open source static JavaScript + HTML application that's deployed in about

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.