-1
I’ve always wondered the syntax of #include
and of #define
, as they differ greatly from the syntax of the rest of the language. I found that this is because these commands are intended for the preprocessor and not the build process "itself".
I also found that compiler manuals like Manual of the GCC discourage the use of the preprocessor, suggesting that the programmer give preference to the mechanisms of the language itself. Example: in section on command #pragma
, modifying the parameters for compilation, it is recommended whenever possible to replace it with function attributes.
However, although the arguments for preference for the compiler seem coherent to me, I have never found a way to use libraries in C/C++ without the pre-processing command #include
. In addition, in order to avoid the inclusion of duplicate headers, it is necessary to use include Guards or the command #pragma once
, both dependent on the preprocessor.
Because C/C++ languages do not support the inclusion of libraries using compiler commands only?
In Pascal and Object Pascal we have the uses
, in C# using
and in Java the import
, among other examples. I know that the C/C++ languages are in constant development and updating until today, so why has this type of feature never been added?
I understand the use of the preprocessor for conditional compilation, especially in the development of compatible functions among several Sos. But wouldn’t using libraries 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".