Is there a tool (or Gcc/Clang flag) that creates a single-header C++ file, from a header file that #include
s multiple other headers (STL and custom ones)? STL header #include
s should be left untouched.
For example, given these files:
// a.h
#pragma once
#include <my_lib/aa.h>
void baz() {}
// aa.h
#pragma once
void foo(int) {}
// b.h
#pragma once
void bar(float) {}
// master.h
#pragma once
#include <string>
#include <my_lib/a.h>
#include <memory>
#include <my_lib/b.h>
#include <vector>
Running the tool on master.h would give this output (whitespace may differ):
#pragma once
#include <string>
void foo(int) {}
void baz() {}
#include <memory>
void bar(float) {}
#include <vector>
If there are any #include
s inside #ifdef
s, they should be dumped as well.