Where could I find function body of "fseek()" and "ftell()"

C

Chen ShuSheng

Hey,
In head file 'stdio.h', I only find the prototype of these two function but
no body.
Could someone pls tell me where their bodies are ?
 
S

spibou

Chen said:
Hey,
Hey

In head file 'stdio.h', I only find the prototype of these two function but
no body.

That's how it works , include headers contain function
prototypes not definitions.
Could someone pls tell me where their bodies are ?

In the files of the person or organization who wrote
the C library you use.That person or organization may
or may not have decided to make these definitions
publically available. If for example you're using the GNU
compiler then the source will be publically available (but I
don't know where off top of my head). With other implementations
it may not. So if you tell us which implementation you're
using we might be able to tell you or direct you to an
appropriate newsgroup.

Spiros Bousbouras
 
C

Chris Dollin

Chen ShuSheng wrote:

(about fseek and ftell)
Hey,
In head file 'stdio.h', I only find the prototype of these two function but
no body.

That's how it's supposed to be.
Could someone pls tell me where their bodies are ?

Supposing we could, what difference would it make to whatever
you want to do? Remember that the code for these functions is
implementation-specific.

If you want to find out what they're /supposed/ to do, read
their descriptions in the Standard or man pages or some
appropriate C book.
 
C

Chen shuSheng

Hey

don't know where off top of my head). With other implementations
it may not. So if you tell us which implementation you're
using we might be able to tell you or direct you to an
appropriate newsgroup.

Spiros Bousbouras
My implementation evironment is : Borland TC2.0.
Could you explain what is implementation-specific? I am not sure of that.
 
S

spibou

Chen said:
My implementation evironment is : Borland TC2.0.
Could you explain what is implementation-specific? I am not sure of that.

What is implementation specific is whether the source code of
the standard library is publicly available or not. In your case I
suspect it isn't but I'm not 100% certain.

Spiros Bousbouras
 
C

Chen shuSheng

What is implementation specific is whether the source code of
the standard library is publicly available or not. In your case I
suspect it isn't but I'm not 100% certain.

Spiros Bousbouras

If the standard library is not publicly available, where the compiler should
go to find the function body? Iam curious.
 
C

Chris Dollin

Chen said:
If the standard library is not publicly available, where the compiler should
go to find the function body?

Typically the compiler doesn't /need/ the function body. Some kind soul has
compiled the code already and put that code somewhere that the implementation
can easily find it.

[The `kind soul` might have been the compiler vendor, as part of delivering
the compiler; or it might be the operating system provider, who may have
made an implementation of the C standard library available by default;
or it /could/ be that the compiler recompiles standard library functions
on demand, in which case it can know what the function body is without
it being anywhere "publically available".]
Iam curious.

Yes.
 
A

Andrew Poelstra

Chen ShuSheng said:
Hey,
In head file 'stdio.h', I only find the prototype of these two function but
no body.
Could someone pls tell me where their bodies are ?

Well, I certainly didn't throw the bodies in the creek behind the mill.




You aren't going to check there, are you?
 
S

Simon Biber

Chen said:
Hey,
In head file 'stdio.h', I only find the prototype of these two function but
no body.
Could someone pls tell me where their bodies are ?

This is a common question that comes up when one is learning C. I
certainly puzzled about it for a while, before I realised with dismay
that the source code of my C library was not available.

You see, some people, probably either the makers of the compiler or the
operating system or the hardware, have a copy of the function bodies but
they don't want to give it away. So, they compile the functions into a
library and just distribute the compiled code. You have no way to get to
the actual implementation since it's already compiled.

However, there are some kind people who created C libraries and made the
source code freely available. Free software projects like GNU's glibc
and newlib come to mind. You can even browse the source on the web these
days, through CVS gateways.

Standard C libraries have been written by many different companies and
people over the years, and some are more portable than others. Reading
through code like fseek and ftell's may involve a lot of system-specific
function calls.
 
J

jmcgill

Chen said:
If the standard library is not publicly available, where the compiler should
go to find the function body? Iam curious.

It's time to learn about object code linkage.
 
F

Flash Gordon

(e-mail address removed) wrote:

publically available. If for example you're using the GNU
compiler then the source will be publically available (but I
don't know where off top of my head). With other implementations

<OT NIT>
The GNU compiler, gcc, is just a compiler not a complete implementation
and does *not* include the library. Normally gcc uses whatever C library
the OS provides and the source code for that library may well not be
available.
 
C

Chen shuSheng

Chris Dollin said:
[The `kind soul` might have been the compiler vendor, as part of
delivering
the compiler; or it might be the operating system provider, who may have
made an implementation of the C standard library available by default;
or it /could/ be that the compiler recompiles standard library functions
on demand, in which case it can know what the function body is without
it being anywhere "publically available".]

I see a directory named "lib" under my IDE 's directory. It is described
as containing "start-up code" and "run-time code". I want to know if the
function body is transfered to "??.obj" file under that directory. I also
want to know which .obj file is the "start-up code" .
 
F

Flash Gordon

Chen said:
Chris Dollin said:
Chen shuSheng wrote:
[The `kind soul` might have been the compiler vendor, as part of
delivering
the compiler; or it might be the operating system provider, who may have
made an implementation of the C standard library available by default;
or it /could/ be that the compiler recompiles standard library functions
on demand, in which case it can know what the function body is without
it being anywhere "publically available".]

I see a directory named "lib" under my IDE 's directory. It is described
as containing "start-up code" and "run-time code". I want to know if the
function body is transfered to "??.obj" file under that directory. I also
want to know which .obj file is the "start-up code" .

Then ask somewhere they know about your IDE, such as groups dedicated to
it or to your OS. We don't deal with the specifics of the thousands of
development systems here. However, unless you are writing code for an
embedded system and you are meant to modify the startup and/or library
code (I've had to, but on those systems the implementer provided and
documented the source because it was one of the situations where the
implementer *wanted* you to deal with some system specifics) there is no
need for you to worry about this. It would generally be as useful as
trying to get the circuit diagrams for your video recorder when you want
to use it to record programs.
 
C

Chen Shusheng

Flash Gordon said:
Chen said:
Chris Dollin said:
Chen shuSheng wrote:
[The `kind soul` might have been the compiler vendor, as part of
delivering
the compiler; or it might be the operating system provider, who may have
made an implementation of the C standard library available by default;
or it /could/ be that the compiler recompiles standard library functions
on demand, in which case it can know what the function body is without
it being anywhere "publically available".]

I see a directory named "lib" under my IDE 's directory. It is
described as containing "start-up code" and "run-time code". I want to
know if the function body is transfered to "??.obj" file under that
directory. I also want to know which .obj file is the "start-up code" .

Then ask somewhere they know about your IDE, such as groups dedicated to
it or to your OS. We don't deal with the specifics of the thousands of
development systems here. However, unless you are writing code for an
embedded system and you are meant to modify the startup and/or library
code (I've had to, but on those systems the implementer provided and
documented the source because it was one of the situations where the
implementer *wanted* you to deal with some system specifics) there is no
need for you to worry about this. It would generally be as useful as
trying to get the circuit diagrams for your video recorder when you want
to use it to record programs.

I understand. What I want to know is not the language itself and it's other
things. Thank you.
 
S

spibou

Chen said:
I'd like to. Could you advise a good book for new comer?

"Expert C programming" by Peter van der Linden
has a chapter on linking. But linking is very platfrom
specific so if you need to understand in every detail
how linking gets done on the platform you're using
then you need to find a book which deals specifically
with your platform.

Spiros Bousbouras
 
J

jmcgill

Chen said:
I'd like to. Could you advise a good book for new comer?

It depends on your platform. Are you using a variety of Unix, or are
you using something weird?
 
C

Chen Shusheng

jmcgill said:
It depends on your platform. Are you using a variety of Unix, or are
you using something weird?

I am now working under Windows Xp. But i want to learn more about open
source. So is red hat linux a good choice or can you suggest one variable of
Unix?
 
A

Andrew Poelstra

Chen Shusheng said:
I am now working under Windows Xp. But i want to learn more about open
source. So is red hat linux a good choice or can you suggest one variable of
Unix?

<OT>
Redhat isn't free anymore, and the free versions aren't supported.
Their free Linux is now called "Fedora" and is community maintained.
It's my favorite Linux for programming.

If you for some reason want a GUI, go with Ubuntu. It has the best
default programming font I've ever seen.
</OT>

Further discussion should be taken elsewhere.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top