This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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]

space between function name and open parenthesis in C++


Hi

   I would like to ask if it is an accepted practice to putting a
space between a function name and the open parenthesis that follows in
C++ code. In libstdc++-v3, I find examples of with both cases:

 __gnu_cxx::__recursive_mutex&
 get_static_mutex()
 {
   static __gthread_once_t once = __GTHREAD_ONCE_INIT;
   __gthread_once(&once, init);
   return *static_mutex;
 }

...

 recursion_push (__guard* g)
 { return ((char *)g)[1]++; }

 static inline void
 recursion_pop (__guard* g)
 { --((char *)g)[1]; }


I tried to find any style guide for C++ code. The only thing I found is the draft of C++ Standard Library Style Guidelines, which says:

"03. Function names and parentheses
 void mangle()
    -NOT-
 void mangle ()  // wrong

    Reason: no space before parentheses (except after a control-flow
    keyword) is near-universal practice for C++.  It identifies the
    parentheses as the function-call operator or declarator, as
    opposed to an expression or other overloaded use of parentheses."

and

"The library currently has a mixture of GNU-C and modern C++ coding
styles.  The GNU C usages will be combed out gradually."

-Doug


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