Skip to main content
added 260 characters in body
Source Link
einpoklum
  • 2.8k
  • 1
  • 18
  • 34

I am maintaining a FOSS library which, for the sake of discussion, consists of a small .h file and a larger .c file. (plus build-related files, see below)

I've been requested to offer this library as a single header file. My instinct was to just refuse, as one could simply include both the .c and and the .h file, but I suppose maybe it's somehow useful for some people to enjoy this single-file convenience.

My question is: How should I arrange for both the two sources to be available, and the single-file version? There seem to be lots of options here:

  • Just duplicate the code, and have another .h with everything in it checked in to the repository.
  • Generate the combined .h as part of the build process - but, how do I do that effectively? Do I use regular expressions? I can't preprocess the files - that will result in all macros being expanded.
  • Switch to having a single .h in the repository, only, and generate the smaller .h dynamically - but then, same problem as the previous item - how does one do that effectively?
  • Decide it's a useless endeavor and refuse to offer a single header file.

What should I know about the feasibility, pros and cons of these options? And - is there other ones I've overlooked?

PS - The library's repository is on GitHub and there are occasional versioned releases of the source code.Notes:

  • The library's repository is on GitHub and there are occasional versioned releases of the source code.
  • I use CMake for build configuration and installation, so solutions requiring automation can rely on this fact. But since I made this a general question, describing other automation schemes is a legitimate answer.

I am maintaining a FOSS library which, for the sake of discussion, consists of a small .h file and a larger .c file.

I've been requested to offer this library as a single header file. My instinct was to just refuse, as one could simply include both the .c and and the .h file, but I suppose maybe it's somehow useful for some people to enjoy this single-file convenience.

My question is: How should I arrange for both the two sources to be available, and the single-file version? There seem to be lots of options here:

  • Just duplicate the code, and have another .h with everything in it checked in to the repository.
  • Generate the combined .h as part of the build process - but, how do I do that effectively? Do I use regular expressions? I can't preprocess the files - that will result in all macros being expanded.
  • Switch to having a single .h in the repository, only, and generate the smaller .h dynamically - but then, same problem as the previous item - how does one do that effectively?
  • Decide it's a useless endeavor and refuse to offer a single header file.

What should I know about the feasibility, pros and cons of these options? And - is there other ones I've overlooked?

PS - The library's repository is on GitHub and there are occasional versioned releases of the source code.

I am maintaining a FOSS library which, for the sake of discussion, consists of a small .h file and a larger .c file (plus build-related files, see below)

I've been requested to offer this library as a single header file. My instinct was to just refuse, as one could simply include both the .c and and the .h file, but I suppose maybe it's somehow useful for some people to enjoy this single-file convenience.

My question is: How should I arrange for both the two sources to be available, and the single-file version? There seem to be lots of options here:

  • Just duplicate the code, and have another .h with everything in it checked in to the repository.
  • Generate the combined .h as part of the build process - but, how do I do that effectively? Do I use regular expressions? I can't preprocess the files - that will result in all macros being expanded.
  • Switch to having a single .h in the repository, only, and generate the smaller .h dynamically - but then, same problem as the previous item - how does one do that effectively?
  • Decide it's a useless endeavor and refuse to offer a single header file.

What should I know about the feasibility, pros and cons of these options? And - is there other ones I've overlooked?

Notes:

  • The library's repository is on GitHub and there are occasional versioned releases of the source code.
  • I use CMake for build configuration and installation, so solutions requiring automation can rely on this fact. But since I made this a general question, describing other automation schemes is a legitimate answer.
Source Link
einpoklum
  • 2.8k
  • 1
  • 18
  • 34

Strategy for offering a library both a single-header and as a header + compiled implementation

I am maintaining a FOSS library which, for the sake of discussion, consists of a small .h file and a larger .c file.

I've been requested to offer this library as a single header file. My instinct was to just refuse, as one could simply include both the .c and and the .h file, but I suppose maybe it's somehow useful for some people to enjoy this single-file convenience.

My question is: How should I arrange for both the two sources to be available, and the single-file version? There seem to be lots of options here:

  • Just duplicate the code, and have another .h with everything in it checked in to the repository.
  • Generate the combined .h as part of the build process - but, how do I do that effectively? Do I use regular expressions? I can't preprocess the files - that will result in all macros being expanded.
  • Switch to having a single .h in the repository, only, and generate the smaller .h dynamically - but then, same problem as the previous item - how does one do that effectively?
  • Decide it's a useless endeavor and refuse to offer a single header file.

What should I know about the feasibility, pros and cons of these options? And - is there other ones I've overlooked?

PS - The library's repository is on GitHub and there are occasional versioned releases of the source code.