Answer the question
In order to leave comments, you need to log in
What to do with includes?
Hello.
In the process of picking another feature, I found that I was missing something like:
#include "my_dir//" + some_const_name + "//my_header.h"
void main() {
use_it(my_const_from_header);
}
Answer the question
In order to leave comments, you need to log in
Well, C++ doesn't do that.
Inserting the results of defines into "#include" is explicitly prohibited, although it might be useful.
If you really really need it - use preliminary code generation, go through the script through the sources and replace some "$placeholder$" with a certain some_const_name should be easy.
No, as long as C++ is alive, so is the preprocessor.
You don't understand correctly. Preprocessor directives are used in almost every C/C++ project. Look at the header files of the standard library. Templates are about something else.
This is greatly exaggerated.
Usage example:
1. When compiling, set your define: /Dsome_const_name via the /D compiler option
2. In the code:
#ifdef some_const_name
#include "my_header.h"
#else
#include "my_other_header.h"
#endif
Just pass the path to the compiler where to look for the headers, that's all
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question