Understanding callback

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

    Understanding callback

    Hello,

    I have seen the WndProc prototyped two ways,

    LONG WINAPI WndProc ( .... );
    and
    LRESULT CALLBACK WndProc ( .... );

    Are these functionally equivalent?
    What are WINAPI and CALLBACK defined as?
    Why are there two ways to go about this?

    Thanks.


    --

    .--------------------.
    | |
    | Good Evening.... | .--.--.
    | | .; .;|;. ;.
    `-------------. ,---' .;_;' `;_;.
    \| ; ;' `; ;
    \ ;;'.--.___.--.`;;
    ;-( o )=3D( o )-;
    ( `--' | `--' )
    \| . . |/
    ........... . .:::::. . .______
    / . '---` . '\
    .' `. .' \
    | ____,.- . | `.....' | _______ |
    | ,-' \ /|\'' \.-- |
    | / \.'\ /,'. \. - |
    | /| ` `\ / \ |
    | ,/ _ '/ '\ |
    ,-' ,-. |o '
    / '| | | | \
    / ,/| |o | \ `
    | .' | |.' |. \ \
    ________/ .'____|________ _______________ _||__`. `__________
    ( \ ) / )
    '-. '-. ( .-` .-`
    '-. .-'--.__. .-.__.--`-. .-`
    '-..' \--' : ~`:=3D,`- `..-`
    \ .. \\ |`-'|`-, /
    \\\\\\\) | |`-'/.'/
    \)\)\\ `-' `-'
    `

  • Keith Thompson

    #2
    Re: Understanding callback

    kid joe <spamtrap@spamt rap.invalidwrit es:
    I have seen the WndProc prototyped two ways,
    >
    LONG WINAPI WndProc ( .... );
    and
    LRESULT CALLBACK WndProc ( .... );
    >
    Are these functionally equivalent?
    What are WINAPI and CALLBACK defined as?
    Why are there two ways to go about this?
    These are specific to Windows. You'll get much better information
    if you post to comp.os.ms-windows.program mer.win32.

    And please use a shorter signature.

    --
    Keith Thompson (The_Other_Keit h) kst-u@mib.org <http://www.ghoti.net/~kst>
    Nokia
    "We must do something. This is something. Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

    Comment

    • jacob navia

      #3
      Re: Understanding callback

      kid joe wrote:
      Hello,
      >
      I have seen the WndProc prototyped two ways,
      >
      LONG WINAPI WndProc ( .... );
      and
      LRESULT CALLBACK WndProc ( .... );
      >
      Are these functionally equivalent?
      Under 32 bit windows they are equivalent.
      Under 64 bit windows they are not since LRESULT
      is a 64 bit type and LONG is a 32 bit type...

      What are WINAPI and CALLBACK defined as?
      WINAPI is _stdcall in 32 Bit windows
      CALLBACK is also defined as _stdcall.

      Under 64 bit windows _stdcall doesn't exist
      so both definitions are equivalent too,
      probably defined as nothing.


      --
      jacob navia
      jacob at jacob point remcomp point fr
      logiciels/informatique

      Comment

      • kid joe

        #4
        Re: Understanding callback

        On Sat, 01 Nov 2008 22:13:40 +0100, jacob navia wrote:
        kid joe wrote:
        >Hello,
        >>
        >I have seen the WndProc prototyped two ways,
        >>
        >LONG WINAPI WndProc ( .... );
        >and
        >LRESULT CALLBACK WndProc ( .... );
        >>
        >Are these functionally equivalent?
        >
        Under 32 bit windows they are equivalent.
        Under 64 bit windows they are not since LRESULT
        is a 64 bit type and LONG is a 32 bit type...
        >
        >
        >What are WINAPI and CALLBACK defined as?
        >
        WINAPI is _stdcall in 32 Bit windows
        CALLBACK is also defined as _stdcall.
        >
        Under 64 bit windows _stdcall doesn't exist
        so both definitions are equivalent too,
        probably defined as nothing.
        Thanks a lot for the info.

        I guess the only remaining question is, why are there these two different
        prototypes for the same function, even if they're functionally equivalent?

        Joe


        --
        .--------------------.
        | |
        | Good Evening.... | .--.--.
        | | .; .;|;. ;.
        `-------------. ,---' .;_;' `;_;.
        \| ; ;' `; ;
        \ ;;'.--.___.--.`;;
        ;-( o )=3D( o )-;
        ( `--' | `--' )
        \| . . |/
        ........... . .:::::. . .______
        / . '---` . '\
        .' `. .' \
        | ____,.- . | `.....' | _______ |
        | ,-' \ /|\'' \.-- |
        | / \.'\ /,'. \. - |
        | /| ` `\ / \ |
        | ,/ _ '/ '\ |
        ,-' ,-. |o '
        / '| | | | \
        / ,/| |o | \ `
        | .' | |.' |. \ \
        ________/ .'____|________ _______________ _||__`. `__________
        ( \ ) / )
        '-. '-. ( .-` .-`
        '-. .-'--.__. .-.__.--`-. .-`
        '-..' \--' : ~`:=3D,`- `..-`
        \ .. \\ |`-'|`-, /
        \\\\\\\) | |`-'/.'/
        \)\)\\ `-' `-'
        `


        Comment

        • Pawel Dziepak

          #5
          Re: Understanding callback

          -----BEGIN PGP SIGNED MESSAGE-----
          Hash: SHA1

          kid joe wrote:
          I guess the only remaining question is, why are there these two different
          prototypes for the same function, even if they're functionally equivalent?
          Despite the fact that implementation is the same, semantic is different.
          CALLBACK informs that it is callback function (called from winapi
          libraries). LRESULT stands for long type that stores function's return
          value. WINAPI is used for functions that are part of WinAPI. LONG is
          just kind of type (that probably has the same size on all platforms).

          MSDN states that the correct prototype is:
          LRESULT CALLBACK WindowProc(...) ;
          What fits my explanation of CALLBACK, WINAPI, LONG and LRESULT semantics.

          These definitions allows to change implementation or hardware platform
          without breaking API compliance.

          Pawel Dziepak

          -----BEGIN PGP SIGNATURE-----
          Version: GnuPG v1.4.9 (GNU/Linux)
          Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

          iEYEARECAAYFAkk Mz5UACgkQPFW+cU iIHNrMVwCfSOOdF s3m1lMnNYDvtzfn MMWS
          NgwAn1JPmkDB7Zk vrPFrAlvNSD6GH6 Rk
          =sDyQ
          -----END PGP SIGNATURE-----

          Comment

          • Ian Collins

            #6
            Re: Understanding callback

            kid joe wrote:
            >
            I guess the only remaining question is, why are there these two different
            prototypes for the same function, even if they're functionally equivalent?
            >
            A windows group would be the place to ask.

            Please don't post such a daft, ill-formed signature.

            --
            Ian Collins

            Comment

            • CBFalconer

              #7
              Re: Understanding callback

              Ian Collins wrote:
              kid joe wrote:
              >
              >I guess the only remaining question is, why are there these two
              >different prototypes for the same function, even if they're
              >functionally equivalent?
              >
              A windows group would be the place to ask.
              >
              Please don't post such a daft, ill-formed signature.
              He ignored the same request posted about 2 hours before his last
              entry. If he continues again I guess the only solution is the
              plonk file. Besides, his queries are all off-topic. He might read
              the following references:

              Some useful references about C:
              <http://www.ungerhu.com/jxh/clc.welcome.txt >
              <http://c-faq.com/ (C-faq)
              <http://benpfaff.org/writings/clc/off-topic.html>
              <http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf(C99)
              <http://cbfalconer.home .att.net/download/n869_txt.bz2 (pre-C99)
              <http://www.dinkumware. com/c99.aspx (C-library}
              <http://gcc.gnu.org/onlinedocs/ (GNU docs)
              <http://clc-wiki.net/wiki/C_community:com p.lang.c:Introd uction>

              --
              [mail]: Chuck F (cbfalconer at maineline dot net)
              [page]: <http://cbfalconer.home .att.net>
              Try the download section.

              Comment

              • Default User

                #8
                Re: Understanding callback

                Keith Thompson wrote:

                And please use a shorter signature.
                Or at the very least a legal signature separator.




                Brian

                Comment

                • George

                  #9
                  Re: Understanding callback

                  On Sat, 01 Nov 2008 22:13:40 +0100, jacob navia wrote:
                  kid joe wrote:
                  >Hello,
                  >>
                  >I have seen the WndProc prototyped two ways,
                  >>
                  >LONG WINAPI WndProc ( .... );
                  >and
                  >LRESULT CALLBACK WndProc ( .... );
                  >>
                  >Are these functionally equivalent?
                  >
                  Under 32 bit windows they are equivalent.
                  Under 64 bit windows they are not since LRESULT
                  is a 64 bit type and LONG is a 32 bit type...
                  >
                  >
                  >What are WINAPI and CALLBACK defined as?
                  >
                  WINAPI is _stdcall in 32 Bit windows
                  CALLBACK is also defined as _stdcall.
                  >
                  Under 64 bit windows _stdcall doesn't exist
                  so both definitions are equivalent too,
                  probably defined as nothing.
                  But it's not just windows stuff.

                  There is an aspect of callback functions that is

                  a) metasyntactic
                  b) relevant to standard C
                  --
                  George

                  Hundreds of thousands of American servicemen and women are deployed across
                  the world in the war on terror. By bringing hope to the oppressed, and
                  delivering justice to the violent, they are making America more secure.
                  George W. Bush

                  Picture of the Day http://apod.nasa.gov/apod/

                  Comment

                  • Wolfgang Draxinger

                    #10
                    Re: Understanding callback

                    Default User wrote:
                    Keith Thompson wrote:
                    >
                    >
                    >And please use a shorter signature.
                    >
                    Or at the very least a legal signature separator.
                    And if the OP wonders how that looks like: It's
                    "-- \n", i.e. 2 dashes, 1 space 1 newline.

                    Wolfgang Draxinger
                    --
                    E-Mail address works, Jabber: hexarith@jabber .org, ICQ: 134682867

                    Comment

                    • kid joe

                      #11
                      Re: Understanding callback

                      Got it, thanks. I guess just not worry about it in practise...

                      Joe

                      PS. For people who had problems with my sig, try using a fixed-width font
                      (i.e. Courier New) - I think you'll like it :-)


                      On Sat, 01 Nov 2008 22:52:21 +0100, Pawel Dziepak wrote:
                      -----BEGIN PGP SIGNED MESSAGE-----
                      Hash: SHA1
                      >
                      kid joe wrote:
                      >I guess the only remaining question is, why are there these two different
                      >prototypes for the same function, even if they're functionally equivalent?
                      >
                      Despite the fact that implementation is the same, semantic is different.
                      CALLBACK informs that it is callback function (called from winapi
                      libraries). LRESULT stands for long type that stores function's return
                      value. WINAPI is used for functions that are part of WinAPI. LONG is
                      just kind of type (that probably has the same size on all platforms).
                      >
                      MSDN states that the correct prototype is:
                      LRESULT CALLBACK WindowProc(...) ;
                      What fits my explanation of CALLBACK, WINAPI, LONG and LRESULT semantics.
                      >
                      These definitions allows to change implementation or hardware platform
                      without breaking API compliance.
                      >
                      Pawel Dziepak
                      >
                      -----BEGIN PGP SIGNATURE-----
                      Version: GnuPG v1.4.9 (GNU/Linux)
                      Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org
                      >
                      iEYEARECAAYFAkk Mz5UACgkQPFW+cU iIHNrMVwCfSOOdF s3m1lMnNYDvtzfn MMWS
                      NgwAn1JPmkDB7Zk vrPFrAlvNSD6GH6 Rk
                      =sDyQ
                      -----END PGP SIGNATURE-----
                      --
                      .--------------------.
                      | |
                      | Good Evening.... | .--.--.
                      | | .; .;|;. ;.
                      `-------------. ,---' .;_;' `;_;.
                      \| ; ;' `; ;
                      \ ;;'.--.___.--.`;;
                      ;-( o )=3D( o )-;
                      ( `--' | `--' )
                      \| . . |/
                      ........... . .:::::. . .______
                      / . '---` . '\
                      .' `. .' \
                      | ____,.- . | `.....' | _______ |
                      | ,-' \ /|\'' \.-- |
                      | / \.'\ /,'. \. - |
                      | /| ` `\ / \ |
                      | ,/ _ '/ '\ |
                      ,-' ,-. |o '
                      / '| | | | \
                      / ,/| |o | \ `
                      | .' | |.' |. \ \
                      ________/ .'____|________ _______________ _||__`. `__________
                      ( \ ) / )
                      '-. '-. ( .-` .-`
                      '-. .-'--.__. .-.__.--`-. .-`
                      '-..' \--' : ~`:=3D,`- `..-`
                      \ .. \\ |`-'|`-, /
                      \\\\\\\) | |`-'/.'/
                      \)\)\\ `-' `-'
                      `



                      Comment

                      • James Kuyper

                        #12
                        Re: Understanding callback

                        kid joe wrote:
                        Got it, thanks. I guess just not worry about it in practise...
                        >
                        Joe
                        >
                        PS. For people who had problems with my sig, try using a fixed-width font
                        (i.e. Courier New) - I think you'll like it :-)
                        Using Courier New didn't make your signature 90% shorter, which is the
                        main thing that needs to be fixed.

                        Comment

                        • Keith Thompson

                          #13
                          Re: Understanding callback

                          kid joe <spamtrap@spamt rap.invalidwrit es:
                          Got it, thanks. I guess just not worry about it in practise...
                          >
                          Joe
                          >
                          PS. For people who had problems with my sig, try using a fixed-width font
                          (i.e. Courier New) - I think you'll like it :-)
                          [...]

                          I use a fixed-width font. The ASCII art you use as a signature is
                          reasonably impressive as ASCII art, but it's *way* too long as a
                          signature. The usual guideline (and I think this may be mentioned in
                          one of the RFCs) is that a signature should be no more than 4 lines,
                          not including the "-- " delimiter.

                          --
                          Keith Thompson (The_Other_Keit h) kst-u@mib.org <http://www.ghoti.net/~kst>
                          Nokia
                          "We must do something. This is something. Therefore, we must do this."
                          -- Antony Jay and Jonathan Lynn, "Yes Minister"

                          Comment

                          • Nick Keighley

                            #14
                            Re: Understanding callback

                            George wrote:
                            On Sat, 01 Nov 2008 22:13:40 +0100, jacob navia wrote:
                            kid joe wrote:
                            I have seen the WndProc prototyped two ways,
                            >
                            LONG WINAPI WndProc ( .... );
                            and
                            LRESULT CALLBACK WndProc ( .... );
                            >
                            Are these functionally equivalent?
                            Under 32 bit windows they are equivalent.
                            Under 64 bit windows they are not since LRESULT
                            is a 64 bit type and LONG is a 32 bit type...
                            What are WINAPI and CALLBACK defined as?
                            WINAPI is _stdcall in 32 Bit windows
                            CALLBACK is also defined as _stdcall.

                            Under 64 bit windows _stdcall doesn't exist
                            so both definitions are equivalent too,
                            probably defined as nothing.
                            >
                            But it's not just windows stuff.
                            >
                            There is an aspect of callback functions that is
                            >
                            a) metasyntactic
                            b) relevant to standard C
                            he wasn't asking about callbacks though. He was asking specific
                            windows related questions that could only be answered by knowing about
                            various MS typedefs.

                            and what do you mean by "metasyntactic" ?
                            Is that like Post Modernism?

                            --
                            Nick Keighley

                            Comment

                            • CBFalconer

                              #15
                              Re: Understanding callback

                              kid joe wrote:
                              >
                              Got it, thanks. I guess just not worry about it in practise...
                              >
                              PS. For people who had problems with my sig, try using a
                              fixed-width font (i.e. Courier New) - I think you'll like it :-)
                              Since you ignore requests about your sig, and also top-post, you
                              have won an entry in the PLONK file. Goodbye.

                              --
                              [mail]: Chuck F (cbfalconer at maineline dot net)
                              [page]: <http://cbfalconer.home .att.net>
                              Try the download section.

                              Comment

                              Working...