cvs.gedasymbols.org/archives/browse.cgi   search  
Mail Archives: geda-help/2012/01/23/15:35:59

X-Authentication-Warning: delorie.com: mail set sender to geda-help-bounces using -f
X-Recipient: geda-help AT delorie DOT com
X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on
ham03.websitewelcome.com
X-Spam-Flag2999: NO
X-Spam-Level2999:
X-Spam-Status2999: "No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham
version=3.3.1
DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gibibit.com;
h=Received:Date:From:To:Subject:Message-ID:In-Reply-To:References:X-Mailer:Mime-Version:Content-Type:Content-Transfer-Encoding:X-BWhitelist:X-Source:X-Source-Args:X-Source-Dir:X-Source-Sender:X-Source-Auth:X-Email-Count:X-Source-Cap;
b=RJaJ340FDhmpiMAaT11TAUG/2MsY8qWZgM84WlcMlMoE+Ge/0jqGeHoxEbpmtwxt0Q1B2CJ/5vWgLNNUv+fEVhU2JzQP/nxHQKtM8D6K6km7lPrGPrxIb3uH1nnHH4r0;
Date: Mon, 23 Jan 2012 12:13:55 -0800
From: Colin D Bennett <colin AT gibibit DOT com>
To: geda-help AT delorie DOT com
Subject: Re: [geda-help] Help, how can I help?
Message-ID: <20120123121355.0d3ea4bc@svelte>
In-Reply-To: <20120122234306.GB13485@malakian.lan>
References: <4F1A1196 DOT 20100 AT gmail DOT com>
<201201210150 DOT q0L1o04r012622 AT envy DOT delorie DOT com>
<4F1C643E DOT 7080503 AT gmail DOT com>
<CAPFCoithVSn-AOggs4nZscwYN+5ejH7Cb38VEHDHFzrVLY7Wxg AT mail DOT gmail DOT com>
<20120122234306 DOT GB13485 AT malakian DOT lan>
X-Mailer: Claws Mail 3.7.9 (GTK+ 2.24.6; x86_64-pc-linux-gnu)
Mime-Version: 1.0
X-AntiAbuse: This header was added to track abuse, please include it with any abuse report
X-AntiAbuse: Primary Hostname - gator297.hostgator.com
X-AntiAbuse: Original Domain - delorie.com
X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse: Sender Address Domain - gibibit.com
X-BWhitelist: no
X-Source:
X-Source-Args:
X-Source-Dir:
X-Source-Sender: spk.venturedesignservices.com (svelte) [65.61.115.34]:5204
X-Source-Auth: colin AT gibibit DOT com
X-Email-Count: 1
X-Source-Cap: c2t5bGVuO3NreWxlbjtnYXRvcjI5Ny5ob3N0Z2F0b3IuY29t
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id q0NKYorh021578
Reply-To: geda-help AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: geda-help AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Sun, 22 Jan 2012 15:43:06 -0800
Andrew Poelstra <asp11 AT sfu DOT ca> wrote:

> Function pointers may not be casted to function pointers of
> different types. (This is very irritating, but it's what the
> standard says.)

I don't see how it's irritating.  It's just the only sane thing to
do.  How is a function pointer usefull unless you know the argument
types?

> Calling a function with an invalid declaration is
> even worse, since it has the same effect without warning the
> compiler. For example, the author does the following:
> 
>   char *malloc();
>   char *s = malloc(BUFSIZ);
> 
> which tells the compiler that malloc() is a function declared as
> 
>   char *malloc (int);

Doesn't the empty argument list in the declaration of malloc()
mean the number and type of arguments is completely unspecified,
equivalent to:

    char *malloc(...);

and that means you could write the following code

    malloc("Hello", 3.54f);
    malloc();

> when in fact it is
> 
>   void *malloc(size_t);
> 
> This is not labelled a pitfall, but it is. If you want malloc,
> include <stdlib.h>. This will give you the correct signature.

A good practice is of course to never declare a function apart from
the “standard” supplied interface in its header.
Header file = interface.
Object file / C source file = implementation.

Regards,
Colin

- Raw text -


  webmaster     delorie software   privacy  
  Copyright 2019   by DJ Delorie     Updated Jul 2019