LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-06-2007, 12:53 AM   #1
jaepi
Member
 
Registered: Apr 2007
Location: Urban Jungle
Distribution: Ubuntu
Posts: 189
Blog Entries: 1

Rep: Reputation: 30
Does fread64 and fwrite64 exist in Linux library?


I was advised by a friend of mine to use fread64, fwrite64 instead of fread and fwrite. Does this exist? Been looking for it's documentation but I haven't found one.
 
Old 11-07-2007, 10:21 AM   #2
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
Yes there are 64 bit versions of fopen and friends. If you have already written your program using fopen, fread etc, you can simply define _FILE_OFFSET_BITS == 64 when you compile, and all fopen calls will be translated to fopen64 automatically.

For example, when building myprog.c, which would usually be built like this (where $ is your shell prompt):
Code:
$ gcc myprog.c -o myprog_32_bit_fh_version
For a 64 bit version you might do it like this:
Code:
$ gcc -D_FILE_OFFSET_BITS=64 myprog.c -o myprog_64_bit_fh_version
You can test to see if your program is using the large file option using strace. For example, if your program opens the file "myfile" for writing:
Code:
$ strace ./myprog_32_bit_fh_version 2>&1 |grep myfile
open("myfile", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3
$ strace ./myprog_64_bit_fh_version 2>&1 |grep myfile
open("myfile", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0666) = 3
Notice the addition of the O_LARGEFILE flag in the 64 bit version.
 
Old 11-09-2007, 11:07 AM   #3
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
info libc has info on those functions. They are essentially interchangeable except that the 64 versions allow indexes and sizes larger than 2GB. I think you need open64 or fopen64 for them to work, though.
ta0kira
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LINUX - linking archive (static library) with shared (dynamic) library gurkama Programming 5 03-04-2007 11:11 PM
A decent audio player with a "music library" feature. does it exist for linux? martinr Linux - Software 12 04-17-2006 03:10 PM
Does a flash library exist for software development? GrumpyEd Programming 2 01-16-2004 07:41 AM
cant get xp and linux to co-exist dooker@paisley Linux - General 2 10-13-2003 07:49 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:53 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration