473,396 Members | 2,010 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

struct FILE in RedHat Linux

Hello,

I am new in C in Programming,
Where could I find the detail about struct FILE in RedHat Linux ?
I have tried to check the stdio.h in /usr/include, but I could not find
the

typedef struct {

} FILE;
Could someone provide the information or URL to find detail of struct
FILE ?
OS : RedHat Linux 2.4.20-8

gcc version : 3.2.2 20030222 (Red Hat Linux 3.2.2-5)

Thank you all in advance !!

Nov 18 '06 #1
11 4745
J
When I tried to compile my code

printf("fout->fd=%d\n", fout->fd);

I got the error message

hw1a.c:259: structure has no member named `fd'

Could anyone give me the detail about the default struct FILE in Linux
?

Thank you

Hello,

I am new in C in Programming,
Where could I find the detail about struct FILE in RedHat Linux ?
I have tried to check the stdio.h in /usr/include, but I could not find
the

typedef struct {

} FILE;
Could someone provide the information or URL to find detail of struct
FILE ?
OS : RedHat Linux 2.4.20-8

gcc version : 3.2.2 20030222 (Red Hat Linux 3.2.2-5)

Thank you all in advance !!
Nov 18 '06 #2
J
When I tried to compile my code

printf("fout->fd=%d\n", fout->fd);

I got the error message

hw1a.c:259: structure has no member named `fd'

Could anyone give me the detail about the default struct FILE in Linux
?

Thank you

Hello,

I am new in C in Programming,
Where could I find the detail about struct FILE in RedHat Linux ?
I have tried to check the stdio.h in /usr/include, but I could not find
the

typedef struct {

} FILE;
Could someone provide the information or URL to find detail of struct
FILE ?
OS : RedHat Linux 2.4.20-8

gcc version : 3.2.2 20030222 (Red Hat Linux 3.2.2-5)

Thank you all in advance !!
Nov 18 '06 #3
J
When I tried to compile my code

printf("fout->fd=%d\n", fout->fd);

I got the error message

hw1a.c:259: structure has no member named `fd'

Could anyone give me the detail about the default struct FILE in Linux
?

Thank you

Hello,

I am new in C in Programming,
Where could I find the detail about struct FILE in RedHat Linux ?
I have tried to check the stdio.h in /usr/include, but I could not find
the

typedef struct {

} FILE;
Could someone provide the information or URL to find detail of struct
FILE ?
OS : RedHat Linux 2.4.20-8

gcc version : 3.2.2 20030222 (Red Hat Linux 3.2.2-5)

Thank you all in advance !!
Nov 18 '06 #4
ju*****@gmail.com writes:
I am new in C in Programming,
Where could I find the detail about struct FILE in RedHat Linux ?
I have tried to check the stdio.h in /usr/include, but I could not find
the

typedef struct {

} FILE;
Could someone provide the information or URL to find detail of struct
FILE ?
You don't need to know. The langauge doesn't define the contents of
type FILE; it doesn't even need to be a struct.

The actual declaration will vary from one system to another; any code
you write that depends on its internals will be unnecessarily
non-portable.

If you're curious, many compilers have an option to show you the
output of the preprocessor phase. Feed it a small source file with a
"#include <stdio.h>". <OT>On your system, use "gcc -E".</OTThe full
declaration of FILE is probably in some other header, included
directly or indirectly from <stdio.h>.

But the only thing you *need* to know about is the functions that take
arguments or return results of type FILE.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 18 '06 #5
"J" <ju*****@gmail.comwrites:
When I tried to compile my code

printf("fout->fd=%d\n", fout->fd);

I got the error message

hw1a.c:259: structure has no member named `fd'

Could anyone give me the detail about the default struct FILE in Linux
?
You just posted the same article three times.

Please don't top-post. For details, read the following:

http://www.caliburn.nl/topposting.html
http://www.cpax.org.uk/prg/writings/topposting.php

Whatever "fout" is, it apparently points to a structure that doesn't
have a member called "fd". See response to your original article.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 18 '06 #6
In article <11**********************@h54g2000cwb.googlegroups .com>,
J <ju*****@gmail.comwrote:
>When I tried to compile my code

printf("fout->fd=%d\n", fout->fd);

I got the error message

hw1a.c:259: structure has no member named `fd'
If what you want is the unix file descriptor of a FILE *, you can get
it more portably (though not within pure standard C of course) with
the "fileno" function.

-- Richard
--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
Nov 18 '06 #7
"Keith Thompson" <ks***@mib.orgwrote in message
news:ln************@nuthaus.mib.org...
ju*****@gmail.com writes:
>Where could I find the detail about struct FILE in RedHat Linux ?
....
>Could someone provide the information or URL to find detail of struct
FILE ?

You don't need to know. The langauge doesn't define the contents of
type FILE; it doesn't even need to be a struct.

The actual declaration will vary from one system to another; any code
you write that depends on its internals will be unnecessarily
non-portable.
Correct.

<OT>
However, since the OP, in another post, shows that he's looking for a
way to find the POSIX file descriptor for a given FILE*. The correct
answer in that case is to use fileno(); it's still not to try to look
inside the FILE*.
</OT>
If you're curious, many compilers have an option to show you the
output of the preprocessor phase. Feed it a small source file with a
"#include <stdio.h>". <OT>On your system, use "gcc -E".</OTThe full
declaration of FILE is probably in some other header, included
directly or indirectly from <stdio.h>.
There's no guarantee that <stdio.hactually defines what's in a FILE.
It may (and is likely to) declare FILE to be an incomplete struct type,
and that is sufficient for the interface into stdio to work, since all
pointers-to-struct are defined to have the same representation. In
fact, any competent implementor will hide the definition of FILE from
users (even with compiler help) and only expose it to the library
internals.

S

--
Stephen Sprunk "God does not play dice." --Albert Einstein
CCIE #3723 "God is an inveterate gambler, and He throws the
K5SSS dice at every possible opportunity." --Stephen Hawking

--
Posted via a free Usenet account from http://www.teranews.com

Nov 19 '06 #8
Stephen Sprunk wrote:
There's no guarantee that <stdio.hactually defines what's in a FILE.
It may (and is likely to) declare FILE to be an incomplete struct type,
No, it may not. FILE is required to be an object type. An incomplete
type is not an object type.

Nov 19 '06 #9
"Harald van Dijk" <tr*****@gmail.comwrites:
Stephen Sprunk wrote:
>There's no guarantee that <stdio.hactually defines what's in a FILE.
It may (and is likely to) declare FILE to be an incomplete struct type,

No, it may not. FILE is required to be an object type. An incomplete
type is not an object type.
In addition, the point of making FILE an object type is so that getc()
and putc(), if implemented as macros, can access its internals.

(This *could* have been done by converting FILE* to some
pointer-to-object type withi getc() and putc(), and it doesn't explain
while FILE is *required* to be an object type, but there's a rationale
in there somewhere.)

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 19 '06 #10
Harald van Dijk wrote:
Stephen Sprunk wrote:
>There's no guarantee that <stdio.hactually defines what's in a FILE.
It may (and is likely to) declare FILE to be an incomplete struct type,

No, it may not. FILE is required to be an object type. An incomplete
type is not an object type.
You are correct. However, FILE *could* be a pointer to an incomplete
type, or a pointer to void, or a simple integer type where the integer
is used by the library to find the real information, all of which would
prevent you from findout out much of use by looking at the definition of
FILE.
--
Flash Gordon
Nov 19 '06 #11
Stephen Sprunk wrote:
"Keith Thompson" <ks***@mib.orgwrote in message
.... snip ...
>
>If you're curious, many compilers have an option to show you the
output of the preprocessor phase. Feed it a small source file
with a "#include <stdio.h>". <OT>On your system, use "gcc -E".
</OTThe full declaration of FILE is probably in some other
header, included directly or indirectly from <stdio.h>.

There's no guarantee that <stdio.hactually defines what's in a
FILE. It may (and is likely to) declare FILE to be an incomplete
struct type, and that is sufficient for the interface into stdio
to work, since all pointers-to-struct are defined to have the same
representation. In fact, any competent implementor will hide the
definition of FILE from users (even with compiler help) and only
expose it to the library internals.
If the implementor wants to supply the (more efficient) macro forms
for getc and putc, he must make the details of FILE visible. This
allows getc and putc to avoid unnecessary system calls and operate
directly on the file buffers (until they need to be reloaded).
That implementor may very well be perfectly competent.

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>
Nov 19 '06 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Richard Welty | last post by:
ok, i'm confused. i have two systems. one is redhat 7.1 (a server in colo, reasonably current), the other is 8.0 (my laptop). the server in colo is running postgresql 7.3.2 along with redhat's...
3
by: TonyHa | last post by:
Hello I try to install boost_1_33_1 on RedHat Linux. I have downloaded boost into /user/dtgtools/tmp and I try to install it into /user/dtgtools/packages/boost. I use the following commands:...
1
by: tadiruso | last post by:
hello, i would like to know how to write a code in python to find the encoding of a file in linux. i require it urgently. please help! thanx in advance.
1
by: RubyNovice | last post by:
User Community, I just registered on TheScripts.com and I'm looking for help building an intranet for my employer using Ruby on Rails running on RedHat Linux. I'm new to Ruby; I just purchased my...
2
by: susmithajose | last post by:
how can set a password for a file in linux using c/c++
3
by: muruga | last post by:
Hi to everybody can any one give me suggestions about how to download mysql query browser for redhat linux 9.0 for mysql version 3.23.54. I had tried it by downloading...
0
by: Anna C. Dent | last post by:
srb wrote: $ export DISPLAY=myhost:0.0 and have a functioning X-server on myhost I suspect that LD_LIBRARY_PATH does not contain the directory where libjvm.so resides; such as...
2
by: xtremebass | last post by:
Hi Bytes, in Linux , is it possible to redirect Mysql table output to a file in Linux. i tried it, shows error , but output has displayed in linux prompt when no redirection of file has given(say...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.