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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T21:55:31+00:00 2026-06-13T21:55:31+00:00

Although I am not an experienced programmer in C, I have to use this

  • 0

Although I am not an experienced programmer in C, I have to use this language at work to build a static library which compiles both on SunOS and Win32. This library has just a few source files and their correspondent headers (let’s say: a.c, b.c, a.h and b.h). The project compiles in both platforms and the library mylib.a is generated.

My problem is how to expose the implemented functions of mylib.a to other projects, because when I add both a.h and b.h I get some macro redefinition errors.

EDIT: I found that the macro redefinition error was because of a macro definition into the compilation command (not related to my headers) and it is solved 🙂 But still I would like advice on organizing my source and header files.

My doubt is whether I modify a.h and b.h to be used externally or if I should create a header file specifically for declaring the interface of this library (let’s say mylib.h). I would not like to overcomplicate the original headers, but I would not like to have to keep a different header in sync … I would like to hear from more experienced C programmers about their patterns, advantages of each approach and whether there are other options.

Thank you in advance.

EDIT: seems I have not provided enough information; the schema below tries to show how my files are organised: each code file only includes its header, each header has a guard condition, each header includes a common header, this common header includes all headers.

// a.c ----
#include "a.h"

// b.c ----
#include "b.h"

// a.h ----
#ifndef GUARD_A_H
#define GUARD_A_H
  # include "liball.h"
  void function_prototypes_implemented_in_a();
#endif // GUARD_A_H

// b.h ----
#ifndef GUARD_B_H
#define GUARD_B_H
  # include "liball.h"
  void function_prototypes_implemented_in_b();
#endif // GUARD_B_H

// liball.h ----
#ifndef GUARD_LIBALL_H
#define GUARD_LIBALL_H
  # include <time.h>   // standard headers
  # include <stdioa.h>

  # include "a.h"      // all headers in this project
  # include "b.h"
#endif // GUARD_LIBALL_H
  • 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-13T21:55:35+00:00Added an answer on June 13, 2026 at 9:55 pm

    You should have a public header, mylib.h, that only contains the definitions a user of the library needs to know.

    You then have a private header, mylib-internal.h, that is used within your project. You should not try to keep the two “in sync”, but rather have mylib-internal.h contain #include "mylib.h".

    You should also name all your interface functions like mylib_initialize() etc., and ensure that all private, internal functions are either declared static, or else named _mylib_internal_whatever(), so that users don’t get namespace clashes with other libraries.

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

Sidebar

Related Questions

Although I'm not a .NET developer I always get excited about the work DLR
tried to search for this, although I am not even sure what I am
I have to update old projects at work. I do not have any experience
I am not that experienced with Java/Android programming. I have an array of floats
I am web-designer, not a programmer and a newbie in Javascript / jQuery (although
I have an idea that sounds like it might work but I'm not entirely
I have been using the STOMP protocol in various guises. I have experienced this
I get a random issue with VS2008 (although not that random several times a
Although obviously not all scenarios can be covered by a single design, is it
The problem is not solved although I accepted one answer. Problem: Vim updates very

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.