Re: Problem mit Variablendekleration

Stefan Sander <[email protected]>
Newsgroups gmane.linux.suse.programming
Message-ID <[email protected]>
On Monday 20 June 2005 23:16, Philipp Otte wrote:
> Hi,
> ich habe folgendes Problem. Ich schreibe ein Programm, dass den
> ELF-Header einer ELF-Datei ausliest.
> Das Programm liegt aufs Problem gestutzt als Anhang dabei.
> Dabei gibt mir der gcc folgende Fehlermeldung aus:
>
> philipp@philipp:~$ gcc -o elftest elftest.c
> elftest.c: In Funktion »main«:
> elftest.c:8: error: storage size of `header' isn't known
> elftest.c:13: error: invalid application of `sizeof' to an incomplete
> type
>
> Wieso weiß der gcc nicht, wie groß Elf32_Ehdr ist?
>
> Ich hoffe auf Antworten.
> philipp

#include <stdio.h>
#include <elf.h>

int main(int argc, char* argv[])
{
        FILE *file = NULL;
        Elf32_Ehdr header;
        file = fopen(argv[1], "r");
        if (file == NULL)
                perror("fopen\n");
        if (fread(&header, sizeof(Elf32_Ehdr), 1, file) != 1)
                perror("fread\n");
        return 0;
}

Funktioniert.
liegt wohl an der Definition von Elf32_Ehdr in elf.h

Gruß
Stefan


-- 
Um die Liste abzubestellen, schicken Sie eine Mail an:
    [email protected]
Um eine Liste aller verfügbaren Kommandos zu bekommen, schicken
Sie eine Mail an: [email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.