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

  • Home
  • SEARCH
  • 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 9103197
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T01:34:44+00:00 2026-06-17T01:34:44+00:00

OK, so I know that I should embed my code in namespaces to handle

  • 0

OK, so I know that I should embed my code in namespaces to handle name collisions.
E.g.

My-Header-Only-Library.hpp

    namespace AG {
    namespace My_Header_Only_Library {

    class Foo {
        ...
    };

    }
    }

So I have AG::My_Header_Only_Library::Foo.

Yes, I often use two levels – the first, variously AG, AFG, libAG, etc. – for “my” stuff (I have maintained some of these libraries for decades, e.g. Valid<T>).

And I often have sub-namespaces for various modules.

PROBLEM #1: namespace names sometimes collide.

Yes: I have found collisions for all of the namespace names AG, AFG, libAG. Yes, I have run into companies that have the same initials as me.

(For a while I used GLEW, thinking that this is a fairly unique last name. Back then I was the only Glew on the internet, and only the 48th person with the initials AG on ARPAnet. (AG48). But since then, OpenGL Extensions Wrangler has pretty much taken that away from me.)

I suppose that “namespace AG_some_random_stuff_675567” is less likely to collide. Is that what people do? Use some long namespace name, and then a

using AG_lib = AG_some_random_stuff_675567

Or do you ever try to play tricks like #defining the name of the namespace to something else.

E.g.

#define AG something_more_unique

PROBLEM #2: I sometimes give, loan, allow companies to use my libraries. Bit I ask that they give changes back, i.e. that they do not fork.

Their coding conventions may not be the same.

I don’t want them to change the namespace names, because that makes pulling their changes back harder.

Q: What to do? Have them do

using Their_Name = AG_some_random_stuff_675567
  • 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-06-17T01:34:45+00:00Added an answer on June 17, 2026 at 1:34 am

    I usually start with something about what the namespace contains, my full name, and the creation date — in theory this isn’t 100% immune to collisions either, but it’s pretty close1. If you really want something a lot closer to immune, you can generate a GUID and use that instead.

    Then, of course yes, there’s a much shorter alias for most normal use. Unfortunately, you can’t always use an alias in place of the full namespace name, but such is life.


    1. At least for me it’s pretty close — a more common name would provide a lot less protection though.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know that we should only create repositories for Aggregate Roots and not for
I know that c++ code should be compiled and linked by g++, not gcc.
I know that the following code should show and hide a tiny circular progress
I know that I should put all the html elements in body tag, but
I know that I should have schema of a table before calling NewRow method
I know that I should setup the trap service on each devices seperately but
this is my first question here :) I know that I should not check
I want to know that how one should proceed in building animated splash screen.
I know that the reminder application should display a badge or sound or kind
I know that a command line application should return 0 on success. But are

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.