Description
I very like the concept of single header libraries and I prefer to use them instead of others when I have a choice. Usually they have special macro that you need to declare before including them to indicate that they need to include implementation of all functions. For example:
In exactly one .cpp file we write:
#define SOME_LIB_IMPLEMENTATION
#include <some-lib.h>
And in all others we write just
#include <some-lib.h>
This library can be included in multiple files without any compiler errors but still it compiles multiple times. And some times there are reasons to even create separate .cpp file for header compilation so it takes less memory to compile the whole project. For example, in one of my projects I use Qt and I include this lib in MainWindow class. If i remove inclusion of header it takes about 180MB less to compile this one source file. To compile it separately it uses much less than 180MB RAM. Of course 180MB RAM is not very much for a normal PC but it is quite a lot for virtual machine since I usually don't allocate much memory for them.
So I propose to separate all implementation to define-protected part of the header. And user will have to define some constant like PORTABLE_FD_IMPLEMENTATION before including this header in file where user wants to put implementation. All other files will use lightweight header.
As a side effect it will make a cleaner interface. I mean it will be easier to see it in header without scrolling hundreds of lines.