Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Keith Thompson <kst-u@mib.org> |
| Newsgroups | comp.lang.c |
| Subject | Re: Casting function pointers to different signatures |
| Date | Thu, 23 Apr 2015 18:36:04 -0700 |
| Organization | None to speak of |
| Lines | 33 |
| Message-ID | <874mo6i9yz.fsf@kst-u.example.com> (permalink) |
| References | <9938e88b-965b-4d07-8e86-62b3afa07849@googlegroups.com> <55395FD4.90707@verizon.net> <chine.bleu-30B535.16080523042015@news.eternal-september.org> |
| Mime-Version | 1.0 |
| Content-Type | text/plain |
| Injection-Info | mx02.eternal-september.org; posting-host="9be37d943435275679235b07c7947eef"; logging-data="18424"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+rKJ/aBMVNqoY26/T0J10F" |
| User-Agent | Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) |
| Cancel-Lock | sha1:LRHHIb9OTPUSJYnjp+RV0TOrwpg= sha1:mJcAKBVvmczjLOCrLsAYvb11wQg= |
| Xref | csiph.com comp.lang.c:60968 |
Show key headers only | View raw
Siri Cruz <chine.bleu@yahoo.com> writes:
> In article <55395FD4.90707@verizon.net>, James Kuyper <jameskuyper@verizon.net>
> wrote:
>> > Is it legal/defined-behavior if I cast print_with_brackets to void (*)
>> > (void*) and pass it as the first argument to print_array, e.g. as in the
>> > following?
>
>> "A pointer to a function of one type may be converted to a pointer to a
>> function of another type and back again; the result shall compare equal
>> to the original pointer. If a converted pointer is used to call a
>
>> As a practical matter, you can generally count on void* and char* to be
>> interchangeable - but I think you'd be doing better to make sure that
>
> Legal/defined-behaviour has to be in reference to what standard you're using. C?
> Posix? Microsoft? Windows 95? I write code that's intended for unices (MacOSX
> and Linux at the moment), and on unices all pointers, including function and
> data pointers, are identical.
I don't think POSIX guarantees that, though the definition of dlsym()
nearly nearly implies it.
> So you write to your intended customer base.
I prefer to write to the standard when it's practical. Sometimes
non-portable assumptions can make things easier, but in my experience
that happens less often than some might assume.
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Casting function pointers to different signatures samuelallenalexander@gmail.com - 2015-04-23 13:39 -0700
Re: Casting function pointers to different signatures Barry Schwarz <schwarzb@dqel.com> - 2015-04-23 14:01 -0700
Re: Casting function pointers to different signatures James Kuyper <jameskuyper@verizon.net> - 2015-04-23 17:10 -0400
Re: Casting function pointers to different signatures samuelallenalexander@gmail.com - 2015-04-23 14:39 -0700
Re: Casting function pointers to different signatures James Kuyper <jameskuyper@verizon.net> - 2015-04-23 18:04 -0400
Re: Casting function pointers to different signatures samuelallenalexander@gmail.com - 2015-04-23 15:49 -0700
Re: Casting function pointers to different signatures James Kuyper <jameskuyper@verizon.net> - 2015-04-23 19:22 -0400
Re: Casting function pointers to different signatures samuelallenalexander@gmail.com - 2015-04-24 10:42 -0700
Re: Casting function pointers to different signatures James Kuyper <jameskuyper@verizon.net> - 2015-04-24 14:18 -0400
Re: Casting function pointers to different signatures samuelallenalexander@gmail.com - 2015-04-24 12:36 -0700
Re: Casting function pointers to different signatures James Kuyper <jameskuyper@verizon.net> - 2015-04-24 15:50 -0400
Re: Casting function pointers to different signatures Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-04-24 13:18 -0700
Re: Casting function pointers to different signatures Siri Cruz <chine.bleu@yahoo.com> - 2015-04-23 16:08 -0700
Re: Casting function pointers to different signatures Keith Thompson <kst-u@mib.org> - 2015-04-23 18:36 -0700
Re: Casting function pointers to different signatures Siri Cruz <chine.bleu@yahoo.com> - 2015-04-23 19:00 -0700
Re: Casting function pointers to different signatures raltbos@xs4all.nl (Richard Bos) - 2015-04-25 10:48 +0000
Re: Casting function pointers to different signatures Tim Rentsch <txr@alumni.caltech.edu> - 2015-04-25 04:05 -0700
Re: Casting function pointers to different signatures Lőrinczy Zsigmond <nospam@for.me> - 2015-04-24 06:51 +0200
Re: Casting function pointers to different signatures Richard Damon <Richard@Damon-Family.org> - 2015-04-25 10:57 -0400
csiph-web