Compile error: invalid type modifier within pointer declarator

Discussion in 'C++' started by Per Johansson, Oct 31, 2004.

  1. Compiling code using GCC 3.2.2 with the following function declaration
    give this error.

    extern void APIENTRY glutDisplayFunc (void (* APIENTRY)(void));

    Changing to:

    extern void APIENTRY glutDisplayFunc (void (*)(void));

    fixes the error.

    APIENTRY is a macro defined as "_SYSTEM".

    What is wrong with the original declaration?

    --
    Per Johansson
    Systems developer
    http://per.johansson.name/
    Per Johansson, Oct 31, 2004
    #1
    1. Advertising

  2. Per Johansson

    Mike Wahler Guest

    "Per Johansson" <> wrote in message
    news:TGZvFVipR1cm-pn2-Gnvo9l99zR74@ranavalona...
    > Compiling code using GCC 3.2.2 with the following function declaration
    > give this error.
    >
    > extern void APIENTRY glutDisplayFunc (void (* APIENTRY)(void));
    >
    > Changing to:
    >
    > extern void APIENTRY glutDisplayFunc (void (*)(void));
    >
    > fixes the error.
    >
    > APIENTRY is a macro defined as "_SYSTEM".
    >
    > What is wrong with the original declaration?


    We cannot say, since '_SYSTEM' is not defined by the C++
    language. Perhaps it's an implemenation-specific
    keyword. If it's simply another macro that resolves
    to a valid C++ construct, post it and we'll take a look.

    IOW the best thing is probably to see your documentation
    about 'APIENTRY' and '_SYSTEM'.

    -Mike
    Mike Wahler, Oct 31, 2004
    #2
    1. Advertising

  3. On Sun, 31 Oct 2004 20:17:33 UTC, "Mike Wahler"
    <> wrote:

    >
    > "Per Johansson" <> wrote in message
    > news:TGZvFVipR1cm-pn2-Gnvo9l99zR74@ranavalona...
    > > Compiling code using GCC 3.2.2 with the following function declaration
    > > give this error.
    > >
    > > extern void APIENTRY glutDisplayFunc (void (* APIENTRY)(void));
    > >
    > > Changing to:
    > >
    > > extern void APIENTRY glutDisplayFunc (void (*)(void));
    > >
    > > fixes the error.
    > >
    > > APIENTRY is a macro defined as "_SYSTEM".
    > >
    > > What is wrong with the original declaration?

    >
    > We cannot say, since '_SYSTEM' is not defined by the C++
    > language. Perhaps it's an implemenation-specific
    > keyword. If it's simply another macro that resolves
    > to a valid C++ construct, post it and we'll take a look.
    >
    > IOW the best thing is probably to see your documentation
    > about 'APIENTRY' and '_SYSTEM'.
    >


    I know it's system dependent, a calling convention I suppose. It's
    written like this with gcc -E

    extern void __attribute__((__system__)) glutDisplayFunc (void (*
    __attribute__((__system__)))(void));

    This is a callback function, taking another function as its parameter.
    I was thinking that this kind of modifier is perhaps against the C++
    standard?

    --
    Per Johansson
    Systems developer
    http://per.johansson.name/
    Per Johansson, Nov 3, 2004
    #3
  4. Per Johansson

    Mike Wahler Guest

    "Per Johansson" <> wrote in message
    news:TGZvFVipR1cm-pn2-IP44og5Y1Tg8@ranavalona...
    > On Sun, 31 Oct 2004 20:17:33 UTC, "Mike Wahler"
    > <> wrote:
    >
    > >
    > > "Per Johansson" <> wrote in message
    > > news:TGZvFVipR1cm-pn2-Gnvo9l99zR74@ranavalona...
    > > > Compiling code using GCC 3.2.2 with the following function declaration
    > > > give this error.
    > > >
    > > > extern void APIENTRY glutDisplayFunc (void (* APIENTRY)(void));
    > > >
    > > > Changing to:
    > > >
    > > > extern void APIENTRY glutDisplayFunc (void (*)(void));
    > > >
    > > > fixes the error.
    > > >
    > > > APIENTRY is a macro defined as "_SYSTEM".
    > > >
    > > > What is wrong with the original declaration?

    > >
    > > We cannot say, since '_SYSTEM' is not defined by the C++
    > > language. Perhaps it's an implemenation-specific
    > > keyword. If it's simply another macro that resolves
    > > to a valid C++ construct, post it and we'll take a look.
    > >
    > > IOW the best thing is probably to see your documentation
    > > about 'APIENTRY' and '_SYSTEM'.
    > >

    >
    > I know it's system dependent, a calling convention I suppose. It's
    > written like this with gcc -E
    >
    > extern void __attribute__((__system__)) glutDisplayFunc (void (*
    > __attribute__((__system__)))(void));
    >
    > This is a callback function, taking another function as its parameter.
    > I was thinking that this kind of modifier is perhaps against the C++
    > standard?


    I wouldn't say it's "against" it, but it's not part of it. It's
    an "extension" to it. Check the gcc documentation for its proper
    use.

    -Mike
    Mike Wahler, Nov 7, 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. Vasileios
    Replies:
    4
    Views:
    467
    Rolf Magnus
    Nov 4, 2003
  2. Gil
    Replies:
    0
    Views:
    433
  3. xxx
    Replies:
    7
    Views:
    711
  4. Mark
    Replies:
    2
    Views:
    1,430
    Rolf Magnus
    Jan 25, 2005
  5. Andreas Leitner

    declarator name equals type name weirdness

    Andreas Leitner, Dec 6, 2004, in forum: C Programming
    Replies:
    3
    Views:
    574
    Lawrence Kirby
    Dec 6, 2004
Loading...

Share This Page