Re: C Interview Questions
- From: "William Hughes" <wpihughes@xxxxxxxxxxx>
- Date: 31 Oct 2006 04:45:58 -0800
Richard Heathfield wrote:
Harald van D?k said:
Richard Heathfield wrote:
J. J. Farrell said:
Richard Heathfield wrote:
5. Which of the Following [functions] is not defined in string.h?
All of them, obviously.
Implementation specific, perhaps? Does anything prevent an
implementation defining them in the header if it chooses to?
I can find no licence in the Standard that allows it.
If there is no way for an otherwise strictly conforming program to tell
the difference, there doesn't have to be any explicit licence that
allows it.
Although I don't claim to have thought it through, I can't help wondering
about standard library functions that use static buffers. There may be a
way for strictly conforming programs to detect that, in two different
modules of the program, different static buffers are being used. (And yes,
okay, perhaps the library could be organised to get around this, by using
buffers with external linkage, but it's getting very messy.)
How about not all functions are defined in the header, in particular
no function that uses a static buffer? I.e. could some functions
be defined static in the header (e.g. to simplify inlining)?. As
different
modules would have different versions of the function, this could be
detected by taking function addresses and comparing. But is there
anything in the standard that prevents this?
(Linker magic may be possible, (e.g. for some library functions (even
when declared
static) first resolve the name by looking in a library, and only if it
is not found
there resolve the name using the object file). Do not report name
conflicts
for these library functions. Yech! But is it possible? )
- William Hughes
.
- References:
- C Interview Questions
- From: dhruvaraj
- Re: C Interview Questions
- From: Richard Heathfield
- Re: C Interview Questions
- From: J. J. Farrell
- Re: C Interview Questions
- From: Richard Heathfield
- Re: C Interview Questions
- From: Harald van Dijk
- Re: C Interview Questions
- From: Richard Heathfield
- C Interview Questions
- Prev by Date: Re: need for an extra variable.
- Next by Date: Re: C / asm / long ints
- Previous by thread: Re: C Interview Questions
- Next by thread: debugging
- Index(es):