Default parameters in typedef for function

Discussion in 'C++' started by =?iso-8859-1?Q?Schwarzbauer_G=FCnter?=, Aug 26, 2004.

  1. Hello,

    Does the C++ standard allow default parameters when defining a typedef for a
    function type, e.g.

    typedef void (*TYPE_Report)(const char* message, const char* details = 0);

    This was accepted by MS Visual C++ 6.0, but is rejected in Visual Studio
    ..NET 2003.
    I assume that this change might be because Visual Studio .NET is more C++
    standard compliant than previous versions were.
    Is this correct?

    Is there any way to use default parameters for function types?

    thanks
    Günter
    =?iso-8859-1?Q?Schwarzbauer_G=FCnter?=, Aug 26, 2004
    #1
    1. Advertising

  2. =?iso-8859-1?Q?Schwarzbauer_G=FCnter?=

    Mike Wahler Guest

    "Schwarzbauer Günter" <> wrote in message
    news:...
    > Hello,
    >
    > Does the C++ standard allow default parameters when defining a typedef for

    a
    > function type, e.g.
    >
    > typedef void (*TYPE_Report)(const char* message, const char* details = 0);
    >
    > This was accepted by MS Visual C++ 6.0, but is rejected in Visual Studio
    > .NET 2003.
    > I assume that this change might be because Visual Studio .NET is more C++
    > standard compliant than previous versions were.
    > Is this correct?


    Yes.

    >
    > Is there any way to use default parameters for function types?


    Not that I know of.

    ===================================================================
    ISO/IEC 14882:1998(E)

    8.3.6 Default arguments

    3 A default argument expression shall be specified only in the
    parameter-­declaration­-clause of a function declaration or in
    a template­-parameter (14.1). If it is specified in a parameter­-
    declaration­-clause, it shall not occur within a declarator or
    abstract­-declarator of a parameter­-declaration.(88)


    (88) This means that default arguments cannot appear, for
    example, in declarations of pointers to functions, references
    to functions, or typedef declarations.
    ===================================================================

    -Mike
    Mike Wahler, Aug 26, 2004
    #2
    1. Advertising

  3. "Mike Wahler" <> wrote in message
    news:cFqXc.1082$...
    >
    > "Schwarzbauer Günter" <> wrote in message
    > news:...
    > > Hello,
    > >
    > > Does the C++ standard allow default parameters when defining a
    > > typedef for a function type?

    > Yes.


    Mike , thanks for the quick answer...

    >
    > >
    > > Is there any way to use default parameters for function types?

    >
    > Not that I know of.


    .... although I don't like it.


    Seems like this was no accident, but a deliberate decision.
    Does someone know why this was decided this way?

    Günter
    =?Windows-1252?Q?Schwarzbauer_G=FCnter?=, Aug 26, 2004
    #3
  4. Schwarzbauer Günter wrote:
    > [...]
    > Seems like this was no accident, but a deliberate decision.
    > Does someone know why this was decided this way?


    If somebody does, it would be in comp.std.c++.

    V
    Victor Bazarov, Aug 26, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. BRG
    Replies:
    11
    Views:
    6,375
  2. desktop
    Replies:
    2
    Views:
    454
    Victor Bazarov
    Jun 6, 2007
  3. Chris Dollin

    typedef function with void parameters

    Chris Dollin, Dec 13, 2007, in forum: C Programming
    Replies:
    14
    Views:
    625
    David Thompson
    Dec 24, 2007
  4. oor
    Replies:
    0
    Views:
    1,341
  5. none
    Replies:
    1
    Views:
    932
    Michael Doubez
    Mar 3, 2010
Loading...

Share This Page