title: C library naming conventions
body: <h3>Introduction</h3>
  
  <p>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.</p>
  
  <p>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.</p>
  
  <h3>Question</h3>
  
  <p><strong>How do I prevent naming conflicts between the client code and my C library code?</strong> 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?</p>
  
  <p>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?</p>
  
  <p>I'm very looking forward to the insights I get through your answers!</p>
  
  <h3>EDIT (modified question)</h3>
  
  <p>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: <strong>What possibilities do I have, to let the client choose his own prefix?</strong></p>
  
  <p>The answer <a href="https://stackoverflow.com/users/28169/unwind">Unwind</a> 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)?</p>
  
  <h3>EDIT 2 (status update)</h3>
  
  <p>It all boils down to one of two approaches:</p>
  
  <ul>
  <li>Using a struct</li>
  <li>Using #define (note: There are many ways, how one can use #define to achieve, what I desire)</li>
  </ul>
  
  <p>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.</p>
  
  <p>Finally, I would like to especially thank:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/users/28169/unwind">Unwind</a> - for his sophisticated answer including a full implementation of the "struct-method"</li>
  <li><a href="https://stackoverflow.com/users/48015/christoph">Christoph</a> - for his good answer and pointing me to <a href="https://stackoverflow.com/questions/389827/namespaces-in-c">Namespaces in C</a></li>
  <li>All others - for Your great input</li>
  </ul>
  
  <p>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.</p>