473,395 Members | 1,443 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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,`- `..-`
\ .. \\ |`-'|`-, /
\\\\\\\) | |`-'/.'/
\)\)\\ `-' `-'
`

Nov 1 '08 #1
18 2719
kid joe <sp******@spamtrap.invalidwrites:
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.programmer.win32.

And please use a shorter signature.

--
Keith Thompson (The_Other_Keith) ks***@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"
Nov 1 '08 #2
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
http://www.cs.virginia.edu/~lcc-win32
Nov 1 '08 #3
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,`- `..-`
\ .. \\ |`-'|`-, /
\\\\\\\) | |`-'/.'/
\)\)\\ `-' `-'
`
Nov 1 '08 #4
-----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

iEYEARECAAYFAkkMz5UACgkQPFW+cUiIHNrMVwCfSOOdFs3m1l MnNYDvtzfnMMWS
NgwAn1JPmkDB7ZkvrPFrAlvNSD6GH6Rk
=sDyQ
-----END PGP SIGNATURE-----
Nov 1 '08 #5
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
Nov 1 '08 #6
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:comp.lang.c:Introduction>

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.att.net>
Try the download section.
Nov 2 '08 #7
Keith Thompson wrote:

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


Brian
Nov 2 '08 #8
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/
Nov 2 '08 #9
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: he******@jabber.org, ICQ: 134682867

Nov 2 '08 #10
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

iEYEARECAAYFAkkMz5UACgkQPFW+cUiIHNrMVwCfSOOdFs3m1l MnNYDvtzfnMMWS
NgwAn1JPmkDB7ZkvrPFrAlvNSD6GH6Rk
=sDyQ
-----END PGP SIGNATURE-----
--
.--------------------.
| |
| Good Evening.... | .--.--.
| | .; .;|;. ;.
`-------------. ,---' .;_;' `;_;.
\| ; ;' `; ;
\ ;;'.--.___.--.`;;
;-( o )=3D( o )-;
( `--' | `--' )
\| . . |/
........... . .:::::. . .______
/ . '---` . '\
.' `. .' \
| ____,.- . | `.....' | _______ |
| ,-' \ /|\'' \.-- |
| / \.'\ /,'. \. - |
| /| ` `\ / \ |
| ,/ _ '/ '\ |
,-' ,-. |o '
/ '| | | | \
/ ,/| |o | \ `
| .' | |.' |. \ \
________/ .'____|________________________||__`. `__________
( \ ) / )
'-. '-. ( .-` .-`
'-. .-'--.__. .-.__.--`-. .-`
'-..' \--' : ~`:=3D,`- `..-`
\ .. \\ |`-'|`-, /
\\\\\\\) | |`-'/.'/
\)\)\\ `-' `-'
`

Nov 2 '08 #11
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.
Nov 2 '08 #12
kid joe <sp******@spamtrap.invalidwrites:
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_Keith) ks***@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"
Nov 3 '08 #13
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

Nov 3 '08 #14
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.
Nov 3 '08 #15
CBFalconer <cb********@yahoo.comwrites:
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.
He apparently misunderstood the original requests about his sig,
assuming incorrectly that people were complaining because it doesn't
display properly with a variable-width font. As for top-posting,
that's an easy mistake for a newbie to make, and easy to correct.

Suggested reading for kid joe:
http://www.caliburn.nl/topposting.html
http://www.cpax.org.uk/prg/writings/topposting.php

If he persists in using his inappropriately large sig, then plonking
might be appropriate, but for now I'm going to assume he's educable.

--
Keith Thompson (The_Other_Keith) ks***@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"
Nov 3 '08 #16
In article <ln************@nuthaus.mib.org>,
Keith Thompson <ks***@mib.orgwrote his usual sanctimonious crap,
leading up to:
....
>Suggested reading for kid joe (edited slightly for content):
http://en.wikipedia.org/wiki/Aspergers
http://en.wikipedia.org/wiki/Clique
http://en.wikipedia.org/wiki/C_programming_language

Nov 3 '08 #17
On Mon, 3 Nov 2008 01:14:35 -0800 (PST), Nick Keighley wrote:
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.
That's the only syntax I know for it.
>
and what do you mean by "metasyntactic"?
Is that like Post Modernism?
Aspects of syntax that rise above indidual ones and characterize many.
They're the foo and bar and quuf.
--
George

Faith crosses every border and touches every heart in every nation.
George W. Bush

Picture of the Day http://apod.nasa.gov/apod/
Nov 5 '08 #18
On 5 Nov, 03:54, George <geo...@example.invalidwrote:
On Mon, 3 Nov 2008 01:14:35 -0800 (PST), Nick Keighley wrote:
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?
I don't see how you can answer this without knowing how MS
define LONG and LRESULT
>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?
ditto

>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.
it *is* 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.
I still think this
That's the only syntax I know for it.
but he *** didn't ask a question about callbacks ****

long pippo (long (*Callback)(void*), void*);

that looks a pretty non-Windows way of specifying
a function that takes a callback
and what do you mean by "metasyntactic"?
Is that like Post Modernism?

Aspects of syntax that rise above indidual ones and characterize many.
They're the foo and bar and quuf.
I know what metasyntactic means (eg. see the Jargon file). I don't
understand what foo, bar or pippo (an italian MSV) have to do with
callbacks.
--
Nick Keighley

atheist someone who doesn't believe in god
agnostic someone who isn't sure if he's an atheist
meta-agnostic someone who isn't sure if he's an agnostic
Nov 5 '08 #19

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: scott ocamb | last post by:
hello I have implemented a solution using async methods. There is one async method that can be invoked multiple times, ie there are multiple async "threads" running at a time. When these...
4
by: ma740988 | last post by:
// file sltest.h #ifndef SLTEST_H #define SLTEST_H class CallbackBase // herb shutters gotW source .. { public: virtual void operator()() const { }; virtual ~CallbackBase() = 0; };
15
by: Felix Kater | last post by:
Hi, in a given library I register callback functions with this function: bool set_callback(int index, int (*callback_function)(long)); I need the callback function to also pass the index...
2
by: MR | last post by:
help! I have an unmanaged DLL that I do not have the source code, so i can't recompile or make changes. the DLL requires a callback function. I would like to implement the callback method in a...
6
by: smmk25 | last post by:
Before I state the problem, I just want to let the readers know, I am knew to C++\CLI and interop so please forgive any newbie questions. I have a huge C library which I want to be able to use in...
10
by: SQACPP | last post by:
Hi, I try to figure out how to use Callback procedure in a C++ form project The following code *work* perfectly on a console project #include "Windows.h" BOOL CALLBACK...
0
by: Tim Spens | last post by:
--- On Fri, 6/27/08, Tim Spens <t_spens@yahoo.comwrote: I think I know where the problem is but I'm unsure how to fix it. When I call Register_Handler(...) from python via...
5
by: Jef Driesen | last post by:
I have a C DLL that I want to use from a C# project. The C header file contains these declarations: typedef void (*callback_t) (const unsigned char *data, unsigned int size, void *userdata);...
9
by: Daniel Smedegaard Buus | last post by:
Hey all :) I was wondering about the $error_types (I particularly notice the 's' suffix when reading the manual) parameter for 'set_error_handler()': Can be used to mask the triggering of the...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.