I want to redefine #include to a different word. I don't know if C++ preprocessing can do this, but I am trying:
#define import #include
#define io <iostream>
import io
This doesn't work obviously, so I'm just wondering if I can escape the "#" in the "import #include" statement to completely change it, but this would also require another run-through for the preprocessor I believe. Any input for this would be much appreciated.
Error output is " Stray "#" found in statement... " for anyone who wants to know the error.
EDIT: I looked at the comments, and I now understand more how the c preprocessor works. I didn't really understand it before, but I think I found a work-around. The reason for this was to create a somewhat easy way to convert import statements from one language to include statements in c++. The language was of my own making, and yes, it does things that can't be done in other languages.
You can't redefine #include
via facilities in the C++ language (including the preprocessor), sorry.
But you can preprocess the source code via any program, even one written in C++. Although my impression is that a scripting language is the most common choice. However, only do that for a very good reason.
For example, some people, including myself, think that the preprocessing in the Qt framework is Evil™. It's certainly unnecessary in modern C++, the language after C++11. But that framework predates modern C++.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.