473,396 Members | 2,129 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,396 software developers and data experts.

call back functions...

I am looking for some comprehensive tutorials on how to write call
back functions in C. Can anyone help me?

- sameer oak.

Jun 28 '07 #1
11 2370
sa********@gmail.com wrote:
I am looking for some comprehensive tutorials on how to write call
back functions in C. Can anyone help me?
Write a callback function in the same way you write
any other function. There is nothing "different" about a
callback function, nothing at all. It's just a function.

--
Eric Sosman
es*****@acm-dot-org.invalid
Jun 28 '07 #2
On Thu, 28 Jun 2007 02:57:06 -0700, "sa********@gmail.com"
<sa********@gmail.comwrote:
>I am looking for some comprehensive tutorials on how to write call
back functions in C. Can anyone help me?
It depends on who is calling your function and what you want the
function to do for them. Probably the simplest example is the compare
function passed to qsort. There should be at least one example in
your reference which will show you how to obtain the arguments passed
as generic pointers and return a result. Anything else will require
more detail from you.
Remove del for email
Jun 28 '07 #3
sa********@gmail.com skrev:
I am looking for some comprehensive tutorials on how to write call
back functions in C. Can anyone help me?

- sameer oak.
check here
http://en.wikipedia.org/wiki/Callback_(computer_science)
Jun 28 '07 #4
On Jun 28, 2:57 pm, "sameer....@gmail.com" <sameer....@gmail.com>
wrote:
I am looking for some comprehensive tutorials on how to write call
back functions in C. Can anyone help me?
There is a function pointer tutorial which includes this topic,
you can find that here:
http://prokutfaq.byethost15.com/EBooks
http://www.newty.de/fpt/index.html

-
Sharath

Jun 28 '07 #5
sa********@gmail.com wrote:
I am looking for some comprehensive tutorials on how to write call
back functions in C. Can anyone help me?
They're just functions that have to fit the appropriate callback
contract; there's nothing special about them as far as C is concerned.

What problem are you having with them?

--
Chris "there's a song there somewhere" Dollin

Hewlett-Packard Limited Cain Road, Bracknell, registered no:
registered office: Berks RG12 1HN 690597 England

Jun 28 '07 #6
Eric Sosman wrote:
sa********@gmail.com wrote:
>I am looking for some comprehensive tutorials on how to write call
back functions in C. Can anyone help me?

Write a callback function in the same way you write
any other function. There is nothing "different" about a
callback function, nothing at all. It's just a function.
That is to say, the "callback" part is how the function is used, not how
it is defined.
--
clvrmnky <mailto:sp******@clevermonkey.org>

Direct replies will be blacklisted. Replace "spamtrap" with my name to
contact me directly.
Jun 28 '07 #7
In article <Xs*****************@nnrp.ca.mci.com!nnrp1.uunet.c a>,
Clever Monkey <sp******@clevermonkey.org.INVALIDwrote:
>>I am looking for some comprehensive tutorials on how to write call
back functions in C. Can anyone help me?
> Write a callback function in the same way you write
any other function. There is nothing "different" about a
callback function, nothing at all. It's just a function.
>That is to say, the "callback" part is how the function is used, not how
it is defined.
Not entirely. The way that it is used has implications for its
definition.

Callback functions are unusual in that their types are generally
specified by a library, but their definitions are written by the user,
and some or all of their arguments are passed in by the user. As a
result, callbacks are commonly defined to take void * arguments
(allowing the user some flexibility in the values that can be passed)
where a similar function not used as a callback would probably take
more specifically typed arguments.

-- Richard
--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
Jun 28 '07 #8
Richard Tobin wrote:
In article <Xs*****************@nnrp.ca.mci.com!nnrp1.uunet.c a>,
Clever Monkey <sp******@clevermonkey.org.INVALIDwrote:
>>>I am looking for some comprehensive tutorials on how to write call
back functions in C. Can anyone help me?
>> Write a callback function in the same way you write
any other function. There is nothing "different" about a
callback function, nothing at all. It's just a function.
>That is to say, the "callback" part is how the function is used, not how
it is defined.

Not entirely. The way that it is used has implications for its
definition.

Callback functions are unusual in that their types are generally
specified by a library, but their definitions are written by the user,
and some or all of their arguments are passed in by the user. As a
result, callbacks are commonly defined to take void * arguments
(allowing the user some flexibility in the values that can be passed)
where a similar function not used as a callback would probably take
more specifically typed arguments.
I see your point. Upon consideration, I realize I have experience only
with two varieties of callback:

- An function passed to a module to facilitate code generalization.
e.g., a way to provide a function to a module that updates a UI by
calling back to an API that has no knowledge of the UI specifics.

- A generic library call, such as a data structure deletion function, or
the classic sorting function.

In the first case we generally know what sorts of args it will take, and
what type (it does in the legacy code I maintain, anyway). It is just
who is running it, and how exactly they will use it that is unknown to
the provider -- the provider just provides the data in a known format.
In the latter we have to provide a more generic interface.

I'm more familiar with the former, but recently had to implement a map
for a public API, which required a generic dispose() function to be used
as a callback. I'd forgotten the subtleties.
--
clvrmnky <mailto:sp******@clevermonkey.org>

Direct replies will be blacklisted. Replace "spamtrap" with my name to
contact me directly.
Jun 29 '07 #9
Richard Tobin wrote:
In article <Xs*****************@nnrp.ca.mci.com!nnrp1.uunet.c a>,
Clever Monkey <sp******@clevermonkey.org.INVALIDwrote:
>>>I am looking for some comprehensive tutorials on how to write call
back functions in C. Can anyone help me?
>> Write a callback function in the same way you write
any other function. There is nothing "different" about a
callback function, nothing at all. It's just a function.
>That is to say, the "callback" part is how the function is used, not how
it is defined.

Not entirely. The way that it is used has implications for its
definition.

Callback functions are unusual in that their types are generally
specified by a library, but their definitions are written by the user,
[...]
Hmmm: Would you describe main() as a callback function?

:-)

--
Eric Sosman
es*****@acm-dot-org.invalid
Jun 30 '07 #10

"Eric Sosman" <es*****@acm-dot-org.invalidwrote in message
news:Cr******************************@comcast.com. ..
Richard Tobin wrote:
>In article <Xs*****************@nnrp.ca.mci.com!nnrp1.uunet.c a>,
Clever Monkey <sp******@clevermonkey.org.INVALIDwrote:
>>>>I am looking for some comprehensive tutorials on how to write call
back functions in C. Can anyone help me?
>>> Write a callback function in the same way you write
any other function. There is nothing "different" about a
callback function, nothing at all. It's just a function.
>>That is to say, the "callback" part is how the function is used, not how
it is defined.

Not entirely. The way that it is used has implications for its
definition.

Callback functions are unusual in that their types are generally
specified by a library, but their definitions are written by the user,
[...]

Hmmm: Would you describe main() as a callback function?

:-)
Yes. The shell calls it.

--
Free games and programming goodies.
http://www.personal.leeds.ac.uk/~bgy1mm
Jun 30 '07 #11
Malcolm McLean wrote, On 30/06/07 09:41:
>
"Eric Sosman" <es*****@acm-dot-org.invalidwrote in message
news:Cr******************************@comcast.com. ..
>Richard Tobin wrote:
>>In article <Xs*****************@nnrp.ca.mci.com!nnrp1.uunet.c a>,
Clever Monkey <sp******@clevermonkey.org.INVALIDwrote:

>I am looking for some comprehensive tutorials on how to write call
>back functions in C. Can anyone help me?

Write a callback function in the same way you write
any other function. There is nothing "different" about a
callback function, nothing at all. It's just a function.

That is to say, the "callback" part is how the function is used, not
how it is defined.

Not entirely. The way that it is used has implications for its
definition.

Callback functions are unusual in that their types are generally
specified by a library, but their definitions are written by the user,
[...]

Hmmm: Would you describe main() as a callback function?

:-)
Yes. The shell calls it.
That is not always true and in any case does not make it a callback.
However, Richard did not say that the aspects he was specifying were
unique to callbacks.
--
Flash Gordon
Jun 30 '07 #12

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

Similar topics

7
by: Bruce W...1 | last post by:
I'm a PHP newbie coming from experience with ASP.NET. I want to have a separate PHP file to support each HTML PHP page. This would be the equivalent of an ASP.NET code-behind file but using PHP....
0
by: Nashat Wanly | last post by:
HOW TO: Call a Parameterized Stored Procedure by Using ADO.NET and Visual C# .NET View products that this article applies to. This article was previously published under Q310070 For a Microsoft...
39
by: Randell D. | last post by:
Folks, I'm sure this can be done legally, and not thru tricks of the trade - I hope someone can help. I'm writing a 'tool' (a function) which can be used generically in any of my projects. ...
5
by: Anand Ganesh | last post by:
Hi All, I need some help. I am sort of not sure how to approach this problem. I have a MAINPROGRAM. This is the core application. I have asked two of my staff to developed two different...
6
by: Mark Jerde | last post by:
I need to call a Win32 DLL. The API supports both Windows and Linux, but I'm only concerned with Windows. I'd like advice whether I can use C# or whether I'll have to dust off my old C++ books. ...
10
by: bienwell | last post by:
Hi, I have a question about file included in ASP.NET. I have a file that includes all the Sub functions (e.g FileFunct.vb). One of the functions in this file is : Sub TestFunct(ByVal...
6
by: enjoying the view | last post by:
I am working on a school project, trying to build a simple RPC stub generator. The idea is that the generator takes a normal python file with functions defined in it and produces a client and...
11
by: Felix Kater | last post by:
Hi, I can compile and run this code (see below) which twice calls the function f, first with too less, second with too much arguments. But is it legal and free of memory leaks and other...
17
by: Sara | last post by:
Hi, I'm having a problem with my program and I think it stems from me not understand how to call a function and return a int value to main. What I have to do is create a program that runs...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.