I've always been surprised at the syntax of #include
and #define
, since they differ greatly from the syntax of the rest of the language. I have found that this is due to the fact that these commands are intended for the preprocessor and not the compilation process itself.
I also discovered that compiler handbooks like the GCC Handbook discourage the use of the preprocessor, suggesting that the programmer gives preference to the mechanisms of language itself. Example: In the section about the #pragma
command, which modifies the parameters for compilation, if possible replace it with function attributes.
However, although the compiler's arguments seem to me to be consistent, I've never found a way to use libraries in C / C ++ without the #include
preprocessor command. Also, to avoid including duplicate headers, you must use include guards or the command #pragma once
, both dependent on the preprocessor.
In Pascal and Object Pascal we have uses
, in C # using
and in Java import
, among other examples. I know that C / C ++ languages are constantly being developed and updated to this day, so why has this feature never been added?
I understand the use of the preprocessor for conditional compilation, especially in the development of compatible functions across multiple OSs. But using libraries would not be a very basic function to be in charge of the preprocessor? What is the justification for this?
Since I studied the subject, I feel that whenever I use libraries in C / C ++ I am doing a "gambiarra".