google / google/oboe

Please build oboe as a single-header library

Open
#1,101 7 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
C++
Stars
4.1k
Forks
639
Avg merge
2d 23h
Merged PRs (30d)
8

Description

Issue #1072 was closed, but didn't actually address the feature request, seemingly from a mis-understanding of what a "single-header library" is.

A "single-header library" is a library that is trivial to integrate in any system or build system, because all the code, and all the declarations, are available in a single physical header file. When using a single-header library, the only physical file necessary is a single header file, which contains both interface and implementation.

For any file/module that uses the library, you simply
#include "library.h"

In one translation unit, you do:
#define LIBRARY_IMPLEMENTATION
#include "library.h"

This enables all global symbols to be defined, and they all still come from that single header.
Including a library like this in a project is as easy as dropping in the header file, and creating a .cpp file that defines the appropriate symbol and includes the header file.
This means that integrating in build systems is trivial, *no matter what the build system*. From "build.bat" to "IDE specifics" to "automake" to "ninja" -- doesn't matter; integration is trivial! Shared libraries? Static libraries? Debug configurations? Memory checker macros? Doesn't matter; a single file is compiled with the settings I control, and It Just Works (tm.)

To take a look at how one includes and uses a library like "stb_image.h" to see how to make adoption and integration into arbitrary projects a zero-effort proposition!

https://github.com/nothings/stb/blob/master/stb_image.h

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.