[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [CPROG] lseek64 og hvad er _GNU_SOURCE for noget?



On Mon, 28 Jul 2003, donald_j_axel wrote:

> Oprindelig ubesvaret: Hvor kommer oplysningerne fra? 
> Svar: /usr/include/features.h
> 
>    __USE_LARGEFILE      Define correct standard I/O things.
>    __USE_LARGEFILE64    Define LFS things with separate names.
>    __USE_FILE_OFFSET64  Define 64bit interface as default.

Det ser meget rigtigt ud, men det virker ikke.

Denne her virker:
  gcc -o 2g 2g.c -D_FILE_OFFSET_BITS=64

Det der med lseek64() er så slet ikke nødvendigt, og så er jeg rent 
faktisk der henne hvor jeg synes det "ser pænt ud". Jeg er også helt 
enig i at man skal bruge typen "off_t", og så må systemet selv finde 
ud af at få det til at virke alt sammen. Hvis kompileren så ikke kan 
klare 64 bit, ja så er det ærgeligt, og programmet kan så kun håndtere 
mindre filer - og det er sikkert godt nok de fleste steder.

Her koden jeg brugte til at teste med.

#include <stdio.h>
#include <fcntl.h>
#include <sys/types.h>
#include <unistd.h>
#include <features.h>
int main(int argc, char **argv) {
        int fd;
        off_t ot = 0;
        char buf[] = {0,0,0,0};

        printf("sizeof(off_t): %d\n", sizeof(ot));
        if (argc > 1)
                if ((fd = open(argv[1], O_RDWR)) > 0) {
                        printf("File open: %s\n", argv[1]);
                        ot = lseek(fd, 0, SEEK_END);
                        printf("FilePos: %llu\n", ot);
                        write(fd, &buf, sizeof(buf));
                        printf("Bytes appended: %d\n", sizeof(buf));
                        close(fd);
                }

        return 0;
}

/hans
-- 
Hamletsgade 4 - 201, DK-2200 København N, Phone: +45 3582 9079
Schou Industries ApS      http://schou.dk/    CVR: 26 13 44 39
--------------------------------------------------------------
[about too many Linux distros]
Yes, choice is confusing, but it is better than no choice.
					-- Linus Torvalds


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 20:09 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *