Skip to content

Latest commit

 

History

History

single-header

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

pntr - Single-Header Library

Some people prefer single-header libraries, some don't. pntr provides both options to make everyone happy.

Automatic Generation

The single-header file is automatically generated by the build system whenever a contributing file changes, so it should always be identical to the regular headers. All unit tests are executed with both versions to make sure that the single-header file is correct.

Embedded License

The MIT license is embedded in the single-header file, so you really only need to copy one file.

How does it work?

The generator simply executes these steps:

  • Wrap the license into C++ comments.
  • Write a #pragma once directive.
  • For each header file
    • Skip everything until and inclusive the #pragma once directive.
    • Find the first non-empty line which doesn't start with #include <pntr/.
    • Write a comment with the original header file name.
    • Copy all lines starting with the line found before.

Yes, this does require that all header files must have the correct preprocessor directives in the correct order, and that the build system passes the headers in the correct order to the generator. That's less effort than writing a fancy preprocessor with dependency tracking.