-1

ubuntu(9.04)でgccを使用してansi cのプログラミングを開始したばかりです。次のエラー メッセージが表示されます。

エラー メッセージ:

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

おそらくubuntuまたはgccの構成にある、非常に単純な問題だと思います。Linuxでのプログラミングも初めてです。グーグルでヘルプを探し、チュートリアルを実行しましたが、答えが見つかりませんでした。ありがとうございました!

コード:

/* 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);
    }

指図:

~/Documents/projects/Trials$ gcc -Wall -ansi main.c 
4

2 に答える 2

3

表示されているコードが実際にコンパイルしているコードであると本当に確信していますか? 次のエラーが表示されます。

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

しかし、コードには実際には 12 行ありません。

于 2010-04-26T11:44:38.153 に答える
1

ansi-c が好まない "//" をコメント行に使用しました。ご意見をお寄せいただきありがとうございます。

于 2010-04-26T11:56:37.170 に答える