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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:12:17+00:00 2026-05-13T09:12:17+00:00

Introduction Hello folks, I recently learned to program in C! (This was a huge

  • 0

Introduction

Hello folks, I recently learned to program in C! (This was a huge step for me, since C++ was the first language, I had contact with and scared me off for nearly 10 years.) Coming from a mostly OO background (Java + C#), this was a very nice paradigm shift.

I love C. It’s such a beautiful language. What surprised me the most, is the high grade of modularity and code reusability C supports – of course it’s not as high as in a OO-language, but still far beyond my expectations for an imperative language.

Question

How do I prevent naming conflicts between the client code and my C library code? In Java there are packages, in C# there are namespaces. Imagine I write a C library, which offers the operation “add”. It is very likely, that the client already uses an operation called like that – what do I do?

I’m especially looking for a client friendly solution. For example, I wouldn’t like to prefix all my api operations like “myuniquelibname_add” at all. What are the common solutions to this in the C world? Do you put all api operations in a struct, so the client can choose its own prefix?

I’m very looking forward to the insights I get through your answers!

EDIT (modified question)

Dear Answerers, thank You for Your answers! I now see, that prefixes are the only way to safely avoid naming conflicts. So, I would like to modifiy my question: What possibilities do I have, to let the client choose his own prefix?

The answer Unwind posted, is one way. It doesn’t use prefixes in the normal sense, but one has to prefix every api call by “api->”. What further solutions are there (like using a #define for example)?

EDIT 2 (status update)

It all boils down to one of two approaches:

  • Using a struct
  • Using #define (note: There are many ways, how one can use #define to achieve, what I desire)

I will not accept any answer, because I think that there is no correct answer. The solution one chooses rather depends on the particular case and one’s own preferences. I, by myself, will try out all the approaches You mentioned to find out which suits me best in which situation. Feel free to post arguments for or against certain appraoches in the comments of the corresponding answers.

Finally, I would like to especially thank:

  • Unwind – for his sophisticated answer including a full implementation of the “struct-method”
  • Christoph – for his good answer and pointing me to Namespaces in C
  • All others – for Your great input

If someone finds it appropriate to close this question (as no further insights to expect), he/she should feel free to do so – I can not decide this, as I’m no C guru.

  • 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-13T09:12:17+00:00Added an answer on May 13, 2026 at 9:12 am

    I’m no C guru, but from the libraries I have used, it is quite common to use a prefix to separate functions.

    For example, SDL will use SDL, OpenGL will use gl, etc…

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

Sidebar

Related Questions

Introduction : I have prior experience in programming (C, C++, Java), however, this is
Introduction: Now I know this question could be very broad and it would be
Introduction : Hello Everyone, I have been looking for days for a way to
Introduction Hello, I'm that typical programmer that know how to use api, but tend
Introduction Hello. I am a newbie to PHP programming. I have know the basics
-> Short Introduction, you can SKIP this part I'm glad to be able to
Introduction The Model-View-Controller approach has been in my head since before the holidays and
Introduction first, question at the end. Please read carefully! I have a master-detail relation
Introduction I know I'm going to lose a lot of reputation for this question
This code is adapted from mozilla's intro to object oriented js page: Introduction to

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.