D
D
Dolarun2022-03-14 00:36:44
C++ / C#
Dolarun, 2022-03-14 00:36:44

How to make a header file for a static library?

Hello, I have 8 .cpp files and each of them has a .hpp file. I compile a static library and put all .hpp files into 1 .hpp file almost copy-paste:

#ifndef HEADER1__DEF
#define HEADER1__DEF
//Definitions
#endif

#ifndef HEADER2__DEF
#define HEADER2__DEF
//Definitions
#endif

#ifndef HEADER3__DEF
#define HEADER3__DEF
//Definitions
#endif
//......


Is it possible to do so? Is it right? Or are there much better ways?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
Wataru, 2022-03-14
@Dolarun

Why do it? Why are you not satisfied with 8 headers? If you really want to save lines in the code of library users, then you can use the recursiveness of the preprocessor and make a header with 8 includes. You don't need to copy-paste the code.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question