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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T21:51:31+00:00 2026-05-30T21:51:31+00:00

In a library I am maintaining, there are a few functions which depend on

  • 0

In a library I am maintaining, there are a few functions which depend on pthreads. The project uses automake. I want to create a configure option to disable the dependency on pthreads, which should simply not compile those functions. (The reason is for certain cross-compiling and embedded targets.)

Avoiding to compile the file containing these functions works okay so far, but now I realized that these functions and one struct they use are defined in the public headers.

  1. What is the correct approach here, from a library maintenance perspective?
  2. What’s the correct way to make types or functions optional in public headers?

Initially I thought I should turn the headers into autoconf input (.in) files and generate the headers with these functions and types optionally removed.

But then, what about systems that might have different versions of the library installed simultaneously? Normally these should be able to share headers.

Should I make the headers use a preprocessor conditional to avoid these functions, and use pkg-config to specify it as a command-line option?

Another idea is to move these functions and types into their own header, and avoid installing this header when pthreads are disabled. This would mean messing up the organization of the headers slightly, but maybe is the best idea. I want your opinion though, what’s the best way to deal with optional functionality in the public headers of a library?

  • 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-30T21:51:33+00:00Added an answer on May 30, 2026 at 9:51 pm

    Another idea is to move these functions and types into their own header, and avoid installing this header when pthreads are disabled.

    That’d be the cleanest choice. When you enable the option via AC_ARG_ENABLE you can bypass all the pthreads setup as well, of course. With this option, packages that depend on your library will be able to tell easily (via AC_TRY_COMPILE) that the pthread-optional functions are not there instead of AC_TRY_RUN to see if those functions work at runtime.

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

Sidebar

Related Questions

I'm maintaining library written for PHP 5.2 and I'd like to create PHP 5.3-namespaced
Recently I've been maintaining a legacy project written in VC++ 6.0. The code uses
I am maintaining a VS2010 project which has a number of cross-referenced COM libraries.
I have a project which uses Rhino.ActiveRecord's ARRepository, unfortunatly the project is no longer
Prototype library uses $('element-id') or $F('element-id') to get the element or value of a
The library I'm using has class G and class S which inherits G. I
Many library classes in AS3 have read only properties. Is it possible to create
I would like to add Unicode support to a C library I am maintaining.
To avoid maintaining complex data structures, I want to allocate blocks with quite large
I'm maintaining a PHP library that is responsible for fetching and storing incoming data

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.