Re: "Writing" instead of "Warning" in dlopen(3) manpage

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Mike,

On Fri, Jan 3, 2014 at 1:33 AM, Mike Frysinger <vapier@xxxxxxxxxx> wrote:
> On Thursday 02 January 2014 04:33:30 Michael Kerrisk (man-pages) wrote:
>> On Thu, Jan 2, 2014 at 5:06 PM, Mike Frysinger <vapier@xxxxxxxxxx> wrote:
>> > On Wednesday 01 January 2014 20:46:59 Michael Kerrisk (man-pages) wrote:
>> >> Nevertheless, some compilers
>> >> (e.g., gcc with the '-pedantic' option) may complain about the cast
>> >> used in this program. */
>> >
>> > three things:
>> >  - i think the ISO C standard is required to at least emit a warning
>>
>> Yes, but it's not quite clear to me if the POSIX.1-2013 is meaning
>> that compilers should not issue a warning in this case. Maybe I'm
>> misunderstanding something, though.
>
> true.  in this particular case, it's probably not worth being super pedantic
> since we covered our bases earlier on.
>
> overall question: should the new comment block live above or below the example
> call ?  it's currently below, but i kind of favor putting it before.  i know
> as the content flows, the current one makes a bit of sense (show the right
> answer, and then as an aside, mention the portability issue), but the comment
> is specifically covering this line, so putting it above the line it is
> discussing is a bit more standard i think in the coding world.

I kind of prefer it as an aside, following the code, but I've now also
added some words to more explicitly indicate that the comment refers
to the code above it.

Cheers,

Michael

    cosine = (double (*)(double)) dlsym(handle, "cos");

    /* According to the ISO C standard, casting between function
       pointers and 'void *', as done above, produces undefined results.
       POSIX.1-2003 and POSIX.1-2008 accepted this state of affairs and
       proposed the following workaround:

           *(void **) (&cosine) = dlsym(handle, "cos");

       This (clumsy) cast conforms with ISO C standard and will avoid
       any compiler warnings.

       The 2013 Technical Corrigendum to POSIX.1-2008 (a.k.a.
       POSIX.1-2013) improved matters by requiring that conforming
       implementations support casting 'void *' to a function pointer.
       Nevertheless, some compilers (e.g., gcc with the '-pedantic'
       option) may complain about the cast used in this program. */

-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux