C declaration

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bibi

    C declaration

    What does the following C declaration means?

    void *(disp)(int))

    I can't even begin to understand it!

    Thank you in advance!

    --B


  • Allan Bruce

    #2
    Re: C declaration


    "Bibi" <bibiNS@yahoo.f r> wrote in message
    news:iY4lc.5779 6$mU6.236096@ne wsb.telia.net.. .[color=blue]
    > What does the following C declaration means?
    >
    > void *(disp)(int))
    >
    > I can't even begin to understand it!
    >
    > Thank you in advance!
    >[/color]

    It is a pointer to a function that returns a void and takes an int as an
    arguement.
    Allan


    Comment

    • Victor Nazarov

      #3
      Re: C declaration

      Bibi wrote:[color=blue]
      > What does the following C declaration means?
      >
      > void *(disp)(int))
      >
      > I can't even begin to understand it!
      >
      > Thank you in advance!
      >
      > --B
      >
      >[/color]

      It is incorrect. What about the brace at the end of the line? If you
      have meant
      void *(disp)(int);
      then this is an equevalent for
      void *disp (int);
      which is the declaration of function with single argument of type int
      which returns pointer to void (nothing).

      vir

      Comment

      • Bibi

        #4
        Re: C declaration

        Thanks!

        --B
        "Allan Bruce" <allanmb@TAKEAW AYf2s.com> a écrit dans le message de news:
        c72mbc$b33$1@ne ws.freedom2surf .net...[color=blue]
        >
        > "Bibi" <bibiNS@yahoo.f r> wrote in message
        > news:iY4lc.5779 6$mU6.236096@ne wsb.telia.net.. .[color=green]
        > > What does the following C declaration means?
        > >
        > > void *(disp)(int))
        > >
        > > I can't even begin to understand it!
        > >
        > > Thank you in advance!
        > >[/color]
        >
        > It is a pointer to a function that returns a void and takes an int as an
        > arguement.
        > Allan
        >
        >[/color]


        Comment

        • Thomas stegen

          #5
          Re: C declaration

          Allan Bruce wrote:
          [color=blue]
          > "Bibi" <bibiNS@yahoo.f r> wrote in message
          > news:iY4lc.5779 6$mU6.236096@ne wsb.telia.net.. .
          >[color=green]
          >>What does the following C declaration means?
          >>
          >>void *(disp)(int))[/color][/color]

          [color=blue]
          >
          > It is a pointer to a function that returns a void and takes an int as an
          > arguement.[/color]

          Err, nope... Assuming
          void *(disp)(int);

          Then it is a function prototype for a function called disp
          which returns a pointer to void and takes an int as the argument.

          --
          Thomas.

          Comment

          • osmium

            #6
            Re: C declaration

            Bibi writes:
            [color=blue]
            > What does the following C declaration means?
            >
            > void *(disp)(int))
            >
            > I can't even begin to understand it![/color]

            It is a fragment of something. There is no semi colon and there are
            mismatched parens. Try to type more carefully.


            Comment

            • Allan Bruce

              #7
              Re: C declaration


              "Thomas stegen" <tstegen@cis.st rath.ac.uk> wrote in message
              news:c72o3b$gll 25$1@ID-228872.news.uni-berlin.de...[color=blue]
              > Allan Bruce wrote:
              >[color=green]
              > > "Bibi" <bibiNS@yahoo.f r> wrote in message
              > > news:iY4lc.5779 6$mU6.236096@ne wsb.telia.net.. .
              > >[color=darkred]
              > >>What does the following C declaration means?
              > >>
              > >>void *(disp)(int))[/color][/color]
              >
              >[color=green]
              > >
              > > It is a pointer to a function that returns a void and takes an int as an
              > > arguement.[/color]
              >
              > Err, nope... Assuming
              > void *(disp)(int);
              >
              > Then it is a function prototype for a function called disp
              > which returns a pointer to void and takes an int as the argument.
              >[/color]

              so it is, I should have read more carefully, if the OP had asked about

              void (*disp)(int);

              then that is a pointer to a function. The OPs function can be rewritten as:

              void * disp(int);

              which is a 'normal' function called disp returning a void pointer.

              Allan


              Comment

              • Bibi

                #8
                Re: C declaration

                "Allan Bruce" <allanmb@TAKEAW AYf2s.com> a écrit dans le message de news:
                c72p92$c0l$1@ne ws.freedom2surf .net...[color=blue]
                >
                > "Thomas stegen" <tstegen@cis.st rath.ac.uk> wrote in message
                > news:c72o3b$gll 25$1@ID-228872.news.uni-berlin.de...[color=green]
                > > Allan Bruce wrote:
                > >[color=darkred]
                > > > "Bibi" <bibiNS@yahoo.f r> wrote in message
                > > > news:iY4lc.5779 6$mU6.236096@ne wsb.telia.net.. .
                > > >
                > > >>What does the following C declaration means?
                > > >>
                > > >>void *(disp)(int))[/color]
                > >
                > >[color=darkred]
                > > >
                > > > It is a pointer to a function that returns a void and takes an int as[/color][/color][/color]
                an[color=blue][color=green][color=darkred]
                > > > arguement.[/color]
                > >
                > > Err, nope... Assuming
                > > void *(disp)(int);
                > >
                > > Then it is a function prototype for a function called disp
                > > which returns a pointer to void and takes an int as the argument.
                > >[/color]
                >
                > so it is, I should have read more carefully, if the OP had asked about
                >
                > void (*disp)(int);
                >
                > then that is a pointer to a function. The OPs function can be rewritten[/color]
                as:[color=blue]
                >
                > void * disp(int);
                >
                > which is a 'normal' function called disp returning a void pointer.
                >
                > Allan
                >
                >[/color]

                Well sorry for the mistake. it was in fact
                void *(disp)(int)
                It was in the argument of the function sigset(2).
                void(*sigset(in t sig, void (*disp)(int)))( int);
                Now it makes sense to me.
                Thank you all!

                --B






                Comment

                • Emmanuel Delahaye

                  #9
                  Re: C declaration

                  In 'comp.lang.c', "Bibi" <bibiNS@yahoo.f r> wrote:
                  [color=blue]
                  > Well sorry for the mistake. it was in fact
                  > void *(disp)(int)[/color]

                  Of course, you meant

                  void (*disp)(int)

                  --
                  -ed- get my email here: http://marreduspam.com/ad672570
                  The C-language FAQ: http://www.eskimo.com/~scs/C-faq/top.html
                  C-reference: http://www.dinkumware.com/manuals/reader.aspx?lib=c99
                  FAQ de f.c.l.c : http://www.isty-info.uvsq.fr/~rumeau/fclc/

                  Comment

                  • James McIninch

                    #10
                    Re: C declaration

                    <posted & mailed>

                    Bibi wrote:
                    [color=blue]
                    > What does the following C declaration means?
                    >
                    > void *(disp)(int))
                    >
                    > I can't even begin to understand it!
                    >
                    > Thank you in advance!
                    >
                    > --B[/color]

                    You are missing a parenthesis, but it says 'disp is a pointer to a function
                    that takes and integer argument'.

                    --
                    remove .spam from address to reply by e-mail.

                    Comment

                    Working...