Domanda

Io sono solo di iniziare la programmazione ANSI C con gcc sotto Ubuntu (9.04). Ottengo seguenti messaggi di errore:

Messaggi di errore:

main.c:6: error: expected identifier or ‘(’ before ‘/’ token
In file included from /usr/include/stdio.h:75,
                 from main.c:9:
/usr/include/libio.h:332: error: expected specifier-qualifier-list before ‘size_t’
/usr/include/libio.h:364: error: expected declaration specifiers or ‘...’ before ‘size_t’
/usr/include/libio.h:373: error: expected declaration specifiers or ‘...’ before ‘size_t’
/usr/include/libio.h:493: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘_IO_sgetn’
In file included from main.c:9:
/usr/include/stdio.h:314: error: expected declaration specifiers or ‘...’ before ‘size_t’
/usr/include/stdio.h:682: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘fread’
/usr/include/stdio.h:688: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘fwrite’
main.c:12: error: expected identifier or ‘(’ before ‘/’ token

Suppongo che sia un problema molto semplice, forse nella configurazione di Ubuntu o gcc. Sono nuovo di programmare sotto linux pure. I Googled per un aiuto e ha attraversato un esercitazione , ma non ci sono riuscita trova una risposta. Grazie!

codice:

/* cheat with the preprocessor to skip over missing lines to attempt
   to duplicate the circumstance of the original code */
#line 9
// #include <some_random_header.h>
#include <stdio.h>
#include <math.h>    
int main(int argc, char **argv)
    {
     printf("TestOutput\n");

     return (0);
    }

comando:

~/Documents/projects/Trials$ gcc -Wall -ansi  main.c 
È stato utile?

Soluzione

Sei davvero sicuro che il codice si mostra è il codice in realtà si sta compilando? Si ottiene l'errore:

main.c:12: error: expected identifier or ‘(’ before ‘/’ token

, ma il codice non in realtà hanno 12 linee in esso.

Altri suggerimenti

ho usato "//" per righe di commento, che ANSI-C non piace. Grazie a tutti per il vostro contributo!

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top