質問

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 
役に立ちましたか?

解決

あなたが表示するコードが実際にコンパイルしているコードであると本当に確信していますか?エラーが発生します:

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

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

他のヒント

「//」を使用して、ANSI-Cが好まない行をコメントしました。ご意見ありがとうございます!

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top