Re: calling my custom function same as library function

From: Jack Klein (jackklein_at_spamcop.net)
Date: 02/28/05


Date: Sun, 27 Feb 2005 21:47:30 -0600

On 27 Feb 2005 17:55:39 -0800, "Deniz Bahar" <deniz.bahar@gmail.com>
wrote in comp.lang.c:

> Hi,
>
> I would like to call one of my functions the exact name as an existing
> C library function (for example K&R2 exercises asks me to make an atof
> function). If I don't include the header with the declaration for the
> C library function (stdlib.h in this case) then define/declare my own
> function with the same name, am I safe? It seems to work on my
> compiler, but I wonder if this is portable or even acceptable? thx

According to the C standard, it is neither portable nor acceptable to
use the name of a library function in a context where it has external
linkage.

That means, you can define a function named "atof" if and only if you
define it with the static keyword, which means you can only call it by
name from within the same source file.

Otherwise you generate undefined behavior.

-- 
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~ajo/docs/FAQ-acllc.html


Relevant Pages

  • Re: Purrs all around
    ... My "Purrs all around" post appears in my newsreader under a post you ... made with the exact same subject field, but mine was not a reply to ... the "References" header. ... automatically includes a "References" header that tells everyone's ...
    (rec.pets.cats.anecdotes)
  • Page not showing top/bottom margins
    ... I am having the exact same problem and I think what is ... not showing is the header and footer. ...
    (microsoft.public.word.pagelayout)
  • Re: size problem with ole object data type (blob) and ado.net
    ... The problem is not really in the header of the data. ... But when use .Net I get a file wicth size is the exact double of the ... >> I've a strange problem with ado.net and an Access db. ... >> array of byte to strip every two bytes but the result is an visible ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: size problem with ole object data type (blob) and ado.net
    ... The problem is not really in the header of the data. ... But when use .Net I get a file wicth size is the exact double of the ... >> I've a strange problem with ado.net and an Access db. ... >> array of byte to strip every two bytes but the result is an visible ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: size problem with ole object data type (blob) and ado.net
    ... The problem is not really in the header of the data. ... But when use .Net I get a file wicth size is the exact double of the ... >> I've a strange problem with ado.net and an Access db. ... >> array of byte to strip every two bytes but the result is an visible ...
    (microsoft.public.dotnet.general)