|
Re: FILE Pointer: msg#00252gcc.help
Hi Bharathi, >The sizeof(FILE) is 148 & sizeof(void) is 1. Does it mean anything ? It means the struct FILE is 148 bytes long. And sizeof(void) is probably calculated as if sizeof(char) -- probably something in the standard about that. They could have done... struct FILE { char opaque[148]; }; ...and thus... sizeof(FILE) == 148 What's the sizeof(FILE*) & sizeof(void*)? After all, you don't "malloc(sizeof(FILE))" or "new FILE" in the use of a FILE*. You just use the FILE* returned by the fopen. >and System dependent lib only can process the file descriptor ? Which is why fileno(fp) will tell you the file descriptor. Along with all the other functions I listed, which are the accessors to the FILE structure information. >I try to pass a void ptr to the ftell(), then I got the compilation error "invalid use of void expression". FILE* fp = fopen("foo.txt", "r"); void* vp = fp; size_t position = ftell((FILE*)vp); // Don't forget your cast. >With out casting, How it found that, ptr is NOT a type FILE ? I'm not sure why you'd need to care, but you can use GCC's C++ language extensions to test for type-ness. Sincerely, --Eljay |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | How to write web applications in Linux/C++/X Window?: 00252, Luzhangl |
|---|---|
| Next by Date: | RE: How to write web applications in Linux/C++/X Window?: 00252, Smith, Jacob N. |
| Previous by Thread: | Re: FILE Pointeri: 00252, Bharathi S |
| Next by Thread: | Static libstdc++ and dynamic libs: 00252, Frédéric RISS |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |