This is the mail archive of the gcc-help@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]

position of inline reserved word


Personal predilection:
----------------------

Having first encountered strong typing in Pascal
I am one of those programmers who will forever
write

  char* ptr

rather than

  char *ptr


Issue at hand:
--------------

To make it easy to spot a function name and its
result type I format the definition's function
header across two lines:

  <result-type> <class-name> ::
  <function-name> ( <format-parameters> )

When writing C++ headers I always provide inline
definitions outside of the class declaration.
If this is an inline definition I would like to
write

  <result-type> inline <class-name> ::
  <function-name> ( <format-parameters> )

Unfortunately this only works if <result-type>
is a single identifier.  Consider this example:

  class C {
      int F_simple_type();
      int* F_inline_first();
      int* F_split_type();
      int* F_desired();
      int X;
  };

  int inline C::
  F_simple_type()
  {
      return X;
      
  }

  inline int* C::
  F_inline_first()
  {
      return &X;
      
  }

  int inline *C::
  F_split_type()
  {
      return &X;
      
  }

  int* inline C::
  F_desired()
  {
      return &X;
      
  }

F_simple_type shows that I can use my preferred
format when <result-type> is simple.  F_inline_first
and F_split_type show syntaxes that are accepted by
the g++ 3.4.2 complier.  But when I try use this
preferred format with a complex type (e.g. F_desired)
I get the errors:

  error: expected unqualified-id before "inline"
  error: expected init-declarator before "inline"
  error: expected `,' or `;' before "inline"


Request to list:
----------------

Could someone who is familiar with the C++ standard
explain the logic that makes -- what for at least
some programmers is the clearest format -- invalid?

/john

--
John S. Yates, Jr.   508 665-6897 (voice)
Netezza Inc          508 665-6811 (fax)
200 Crossing Blvd.   Framingham, MA 01701
 


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