public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* position of inline reserved word
@ 2005-07-05 14:52 John Yates
  0 siblings, 0 replies; only message in thread
From: John Yates @ 2005-07-05 14:52 UTC (permalink / raw)
  To: Gcc-Help (E-mail)

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
 

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2005-07-05 14:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-07-05 14:52 position of inline reserved word John Yates

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).