This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Why are we overusing the preprocessor?


Hello,

In going through stl_algo.h (Wouldn't it be easier to distinguish
these headers from the std_xxxx.h headers if we called them
gnu_xxxx.h instead?  I mean the Standard Template Library is
kinda a dated term anyway) I was directed to concept_check.h
and from there to boost_concept_check.h.  I'm finding what I
think are _far_ too many #defines.  #defines, like their
preprocessor cousins #includes, tend to obfuscate things
by making one search/grep all over the place to figure out the
real meaning of a statement.  I know the theory is that brevity
is a blessing - but, IMHO, not at the expense of clarity.

Maybe it's just me, but I tried expanding:

#define _IsUnused __attribute__ ((__unused__))
template < class _Concept > inline void __function_requires()
{
  void (_Concept::*x) () _IsUnused = &_Concept::constraints;
}

#define __glibcpp_function_requires(...)
  __gnu_cxx::__function_requires< __gnu_cxx::__VA_ARGS__ >();

I think it comes out as:

  inline void
  __gnu_cxx::*__VA_ARGS__ () __attribute__ ((__unused__)) =
    &__gnu_cxx::__VA_ARGS__;

but it could be just void instead of inline void and...

I'd bet __VA_ARGS__ is probably something just as horrendous.
Every knowledgeable authority I have read rails against using
the preprocessor, so why is it so commonplace?

--Jeff Turner

Who put the Sam in the "'Sama Laden Ding-Dong"?
                 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]