linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Glynn Clements <glynn@gclements.plus.com>
To: leslie.polzer@gmx.net
Cc: linux-c-programming@vger.kernel.org
Subject: Re: Problem with pointer to external function
Date: Fri, 1 Jul 2005 17:41:01 +0100	[thread overview]
Message-ID: <17093.29213.526059.430091@gargle.gargle.HOWL> (raw)
In-Reply-To: <20050701103026.GA2965@paktahn.black.cat>


leslie.polzer@gmx.net wrote:

> why do it get the segfault below? What's wrong?
> 
> 
> [sky@paktahn ~/code/cbtest]% cat main.c      
> #include <stdio.h>
> 
> typedef void (*callback)();
> 
> extern callback cb;

Is "cd" really a pointer to a function? Or is it a function? If it's
the latter, you need to create a variable of type "callback" and then
make it point to the function, e.g.:

	typedef void (*callback)();
	extern void cb();

	static callback cbp = &cb;

More generally, you have to ensure that the types of "extern"
declarations are correct. The compiler can't check it for you.

-- 
Glynn Clements <glynn@gclements.plus.com>

      parent reply	other threads:[~2005-07-01 16:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-07-01 10:30 Problem with pointer to external function leslie.polzer
2005-07-01 10:54 ` Rechberger Markus
2005-07-01 11:17 ` Steve Graegert
2005-07-01 16:41 ` Glynn Clements [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=17093.29213.526059.430091@gargle.gargle.HOWL \
    --to=glynn@gclements.plus.com \
    --cc=leslie.polzer@gmx.net \
    --cc=linux-c-programming@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).