S
Steven T. Hatton
Stroustrup says this:
http://www.research.att.com/~bs/bs_faq2.html#macro
"So, what's wrong with using macros?"
[...Macros are really bad (I paraphrase - STH)...]
"And yes, I do know that there are things known as macros that doesn't
suffer the problems of C/C++ preprocessor macros. However, I have no
ambitions for improving C++ macros. Instead, I recommend the use of
facilities from the C++ language proper, such as inline functions,
templates, constructors (for initialization), destructors (for cleanup),
exceptions (for exiting contexts), etc."
The GCC documentation says this:
http://gcc.gnu.org/onlinedocs/gcc-3.4.0/gcc/C---Interface.html#C++ Interface
"Declarations and Definitions in One Header"
"C++ object definitions can be quite complex. In principle, your source code
will need two kinds of things for each object that you use across more than
one source file. First, you need an interface specification, describing its
structure with type declarations and function prototypes. Second, you need
the implementation itself. It can be tedious to maintain a separate
interface description in a header file, in parallel to the actual
implementation. It is also dangerous, since separate interface and
implementation definitions may not remain parallel."
[...use our cool #pragmas and don't mess with source/implementation...(I
paraphrase - STH) ]
Now, my question is, can the same thing GCC is doing with #pragmas be done
with something internal to C++? I can't see how. I understand that
#pragma is basically a way for the implementation to introduce behavior not
specified in the standard, so there really isn't a direct contradiction to
what Stroustrup id saying. Nonetheless, I would like to be sure there is
no way to accomplish this within the C++ language proper.
http://www.research.att.com/~bs/bs_faq2.html#macro
"So, what's wrong with using macros?"
[...Macros are really bad (I paraphrase - STH)...]
"And yes, I do know that there are things known as macros that doesn't
suffer the problems of C/C++ preprocessor macros. However, I have no
ambitions for improving C++ macros. Instead, I recommend the use of
facilities from the C++ language proper, such as inline functions,
templates, constructors (for initialization), destructors (for cleanup),
exceptions (for exiting contexts), etc."
The GCC documentation says this:
http://gcc.gnu.org/onlinedocs/gcc-3.4.0/gcc/C---Interface.html#C++ Interface
"Declarations and Definitions in One Header"
"C++ object definitions can be quite complex. In principle, your source code
will need two kinds of things for each object that you use across more than
one source file. First, you need an interface specification, describing its
structure with type declarations and function prototypes. Second, you need
the implementation itself. It can be tedious to maintain a separate
interface description in a header file, in parallel to the actual
implementation. It is also dangerous, since separate interface and
implementation definitions may not remain parallel."
[...use our cool #pragmas and don't mess with source/implementation...(I
paraphrase - STH) ]
Now, my question is, can the same thing GCC is doing with #pragmas be done
with something internal to C++? I can't see how. I understand that
#pragma is basically a way for the implementation to introduce behavior not
specified in the standard, so there really isn't a direct contradiction to
what Stroustrup id saying. Nonetheless, I would like to be sure there is
no way to accomplish this within the C++ language proper.