gccコンパイラのエラーについてstdin

このQ&Aのポイント
  • gccコンパイラを使用してCプログラムをコンパイルする際に、stdin関連のエラーが発生しています。
  • cygwinのgccを使用して、画像を変換するCプログラムをコンパイルしようとしていますが、stdin関連のエラーが発生しています。
  • gccコンパイラのエラー「expected ')' before '->' token」というエラーメッセージが表示され、conv.cファイルのmain関数内でエラーが発生しています。
回答を見る
  • ベストアンサー

gccコンパイラのエラーについてstdin

画像を変換するCプログラムを作成し、cygwinのgccでコンパイルしようとしたところ 以下のエラーが出て困っています。 $ gcc conv.c In file included from conv.c:24:0: conv.c: 関数 ‘main’ 内: conv.c:78:18: エラー: expected ‘)’ before ‘->’ token extern FILE *stdin; ^ conv.c:79:18: エラー: expected ‘)’ before ‘->’ token extern FILE *stdout; ^ conv.c:80:18: エラー: expected ‘)’ before ‘->’ token extern FILE *stderr; 24行目で、#include <stdio.h>を記述しております。 なにが原因でしょうか?

質問者が選んだベストアンサー

  • ベストアンサー
  • Tacosan
  • ベストアンサー率23% (3656/15482)
回答No.2

そう, それが原因. だから, このエラーメッセージはある意味正しい. なぜ書こうという気になったのかはさっぱりわからんが, そんなのは書いちゃいけない.

その他の回答 (1)

  • Tacosan
  • ベストアンサー率23% (3656/15482)
回答No.1

エラーメッセージの最初の In file included from conv.c:24:0: が出てくる理由はよくわからんのだけど, ひょっとして 78行目に extern FILE *stdin; なんて書いてたりする?

yamazakura1977
質問者

補足

78 extern FILE *stdin; 79 extern FILE *stdout; 80 extern FILE *stderr; と、main内の宣言を行っております。 これが原因なのでしょうか?

関連するQ&A

  • typedef部分でのコンパイルエラー

    本に付属のプログラムを動かそうとしているのですが、コンパイルエラーが出て困っています。 言語はC++、コンパイル環境はCygwinでg++です。 typedef CellUtil<ExpressionCell> CellType; extern CellType *uCell; 上記の部分で 106: error: expected init-declarator before '<' token 106: error: expected `,' or `;' before '<' token 107: error: expected init-declarator before '*' token 107: error: expected `,' or `;' before '*' token とエラーが出ます。 CellType *uCell は別のcppファイルで宣言してあります。 typedefでは<>記号は使えたと思うので、何が原因か知っている方教えてください。 本自体も10年前に発行されたものなのでいろいろ困惑しています。 お願いします。

  • stdin,stdoutについて

    C言語を学び始めたものです stdin・stdoutがどのように機能するか分かりません またstdoutはどこに出力しているんですか #include <stdio.h> int main(void) { char ch; while(!feof(stdin)) { scanf("%c", &ch); if(!feof(stdin)) printf("%c", ch); } return 0; } このプログラムは「コンソール」入出力関数だけを使用しテキストファイルの内容を別のテキストファイルにコピーするプログラムだそうですがどのテキストファイルの内容をどこのテキストファイルにコピーしているんですか?stdin・stdoutの機能が全く分かりません。 どなたか分かる方、回答お願いします。

  • コンパイルエラーの英語の読み方

    #include <stdio.h> int main() { printf("Hello, World"; } と書くと error: expected ‘)’ before ‘;’ token error: expected ‘;’ before ‘}’ token と表示されます。 ;の前に)がないと言っているようですが、expectedは名詞の後にくるものだと思うので、 error: ‘)’expected before ‘;’ token だと思うのですが、これについて回答をよろしくお願いします。

  • 下記のプログラムがコンパイラでエラーになります。

    その後のプログラムです。 /************************************************************ 文字列を比較する関数 戻り値 : ps1 > ps2 1 ps1 = ps2 0 ps1 < ps2 -1 *************************************************************/ int str_cmp(char *ps1,char *ps2) /*ps1,ps2 : 比較する文字列が入った配列を指すポインタ*/ { int kekka; /*比較結果*/ for(;*ps1 != '¥0' && *ps2 != '¥0' && *ps1 == *ps2 ;ps1++,ps2++); if (*ps1 > *ps2) { kekka = 1; } else if(*ps1 == *ps2) { kekka = 0; } else { kekka = -1; } return kekka; } /************************************************************* 文字列と文字列とを交換する関数 *************************************************************/ void str_change(char *ps1,char *ps2) /* ps1,ps2 : 交換する文字列が入った配列へのポインタ*/ { char temp[DATA_LEN] /*交換用一時保管*/ str_cpy(temp,ps1); /*複写 ps1->temp */ str_cpy(ps1,ps2); /*複写 ps2->ps1 */ str_cpy(ps2,temp); /*複写 temp->ps2 */ } /************************************************************* 文字列を複写する関数 *************************************************************/ void str_cpy(char *pd,char *ps) /* char *pd :複写される配列へのポインタ*/ /* char *ps :複写する配列へのポインタ*/ { for(;*ps != '¥0';ps++,pd++) { *pd = *ps; /*1文字複写*/ } *pd = '¥0'; /*最後の1文字*/ } これをコンパイルすると kansuu4.c: In function ‘atr_cpy’: kansuu4.c:18: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘main’ kansuu4.c:41: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token kansuu4.c:57: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token kansuu4.c:85: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token kansuu4.c:112: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token kansuu4.c:128: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token kansuu4.c:134: error: expected ‘{’ at end of input と出ました。 本当は自分で努力するべきだと思います。 「自分でよく見てみろ。」 でも結構です。 ご多忙中申し訳ありません。 ご回答の程、宜しくお願い致します。

  • cygwinのgccが、エラーになってしまいます。

    テストプログラム $ cat test.c #include <stdio.h> int main (void) { printf("Hello, World!\n"); return 0; } これを、コンパイルすると $ gcc test.c gcc: error trying to exec '/usr/lib/gcc/i686-pc-cygwin/4.5.3/cc1.exe': execv: Bad address /usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../libcygwin.a(libcmain.o):(.text+0xba): undefined reference to `_WinMain@16' collect2: ld はステータス 1 で終了しました と、このようなエラーが出てきました。 ファイルを確認しても、何も作られていません。 $ ls test.c 対処方法を、ご教示願います。

  • 標準出力と標準エラー出力を時系列にファイルへ

    例として、perlなどで、(test.plとします)  print "stdout1\n";  print STDERR "STDERR1\n";  print "stdout2\n";  print STDERR "STDERR2\n";  print "stdout3\n";  print STDERR "STDERR3\n"; このように、標準出力と、標準エラー出力が混在した状態の処理があった場合、 コマンドプロンプト(Windows2000)にて、 C:\>test.pl とすると、 stdout1 STDERR1 stdout2 STDERR2 stdout3 STDERR3 のように時系列に出力されますが、これをログファイルに取ろうとして、 C:\>test.pl 1>log.txt 2>&1 とすると、 C:\>cat log.txt STDERR1 STDERR2 STDERR3 stdout1 stdout2 stdout3 のように、標準エラー出力が先に吐き出されてしまいます。 これを画面出力時と同様に時系列で取れるようにしたいのですが、どのようにすれば良いでしょうか? 単純なことで困っています。よろしくお願いします。

  • CGIへのコンパイルエラー

    初めまして。プログラミング暦はほとんどありません。javaを少しかじった程度です。今回Ajaxへ挑戦しようと思い、 http://itpro.nikkeibp.co.jp/article/COLUMN/20060115/227278/?ST=nettech の予測補完インタフェースを作成しよとしています。 環境はfedoracore5でXPからのputyからの遠隔です。 complete.cをcomplete.cgiへコンパイルするときに、 [root@localhost html]# gcc -Wall -O2 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include complete.c -o complete.cgi -lglib-2.0 -lsary -lpthread complete.c:1: error: stray ‘\357’ in program complete.c:1: error: stray ‘\273’ in program complete.c:1: error: stray ‘\277’ in program complete.c:1: error: stray ‘#’ in program complete.c:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘<’ token In file included from complete.c:2: /usr/include/string.h:39: error: expected declaration specifiers or ‘...’ before ‘size_t’ /usr/include/string.h:43: error: expected declaration specifiers or ‘...’ before ‘size_t’ /usr/include/string.h:52: error: expected declaration specifiers or ‘...’ before ‘size_t’ /usr/include/string.h:59: error: expected declaration specifiers or ‘...’ before ‘size_t’ /usr/include/string.h:62: error: expected declaration specifiers or ‘...’ before ‘size_t’ /usr/include/string.h:66: error: expected declaration specifiers or ‘...’ before ‘size_t’ /usr/include/string.h:88: error: expected declaration specifiers or ‘...’ before ‘size_t’ /usr/include/string.h:96: error: expected declaration specifiers or ‘...’ before ‘size_t’ /usr/include/string.h:102: error: expected declaration specifiers or ‘...’ before ‘size_t’ /usr/include/string.h:109: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘strxfrm’ /usr/include/string.h:184: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘strcspn’ /usr/include/string.h:188: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘strspn’ /usr/include/string.h:242: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘strlen’ /usr/include/string.h:270: error: expected declaration specifiers or ‘...’ before ‘size_t’ /usr/include/string.h:288: error: expected declaration specifiers or ‘...’ before ‘size_t’ /usr/include/string.h:292: error: expected declaration specifiers or ‘...’ before ‘size_t’ /usr/include/string.h:296: error: expected declaration specifiers or ‘...’ before ‘size_t’ /usr/include/string.h:299: error: expected declaration specifiers or ‘...’ before ‘size_t’ /usr/include/string.h:329: error: expected declaration specifiers or ‘...’ before ‘size_t’ In file included from /usr/include/string.h:417, from complete.c:2: /usr/include/bits/string2.h:969: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__strcspn_c1’ /usr/include/bits/string2.h:971: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__strcspn_c1’ /usr/include/bits/string2.h:979: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__strcspn_c2’ /usr/include/bits/string2.h:982: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__strcspn_c2’ /usr/include/bits/string2.h:991: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__strcspn_c3’ /usr/include/bits/string2.h:994: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__strcspn_c3’ とエラーがでます。どうしたらいいでしょうか?(文字数の関係で半分しか掲載できませんでした。)よろしくお願いいたします。

    • ベストアンサー
    • CGI
  • 標準出力/標準エラー出力を時系列にファイルへ

    画面への文字出力が、標準出力(stdout)と標準エラー出力(stderr)の 両方もつような、コンソールアプリ(exe形式)のツールを動作させたときに、 画面上には、 stdout1 STDERR1 stdout2 STDERR2 stdout3 STDERR3 のような順番で処理順にメッセージが出るのですが、 これをファイルに落とそうとして、  C:\>hoge.exe 1> log.txt 2>1& とすると、log.txtの中身が、 C:\>type log.txt STDERR1 STDERR2 STDERR3 stdout1 stdout2 stdout3 のような標準エラー出力が先に吐き出される順番になってしまっています。 これを、exe実行前に、MS-DOSとして何らかの設定を行うことで、 ファイルに落とした時も、出力された文字が時系列に保存されるように する方法はあるでしょうか? よろしくお願いします。

  • ANSI C コンパイルエラー

    下記のファイルをコンパイルする際にCent OS & Windows7 ではReadme 通りにコンパイルできたんですがMac OSX Lion では以下のエラーが出てしまいます。 http://www.itu.int/rec/T-REC-G.711-200911-I!Amd2/en どのようにしたらよいのでしょうかご教示お願いいたします。 コンパイルエラー ーーーーーーーーーーーーーーーーーーーーーーーー make -C src/mainlib "CC=gcc" "CXX=g++" gcc -O2 -Wall -fno-builtin -DWMOPS=1 -DAPPENDIX_I_POSTFILTER -I../basicOp_stl2005_v2.2 -Iutil -Ig711wbe -Ilower_band -Ihigher_band -Iapp1_postfilter -c util/dsputil.c -o util/dsputil.o In file included from ../basicOp_stl2005_v2.2/stl.h:27, from util/dsputil.h:18, from util/dsputil.c:11: ../basicOp_stl2005_v2.2/basop32.h:52: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘Overflow’ ../basicOp_stl2005_v2.2/basop32.h:53: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘Carry’ ../basicOp_stl2005_v2.2/basop32.h:67: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘add’ ../basicOp_stl2005_v2.2/basop32.h:68: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘sub’ ../basicOp_stl2005_v2.2/basop32.h:69: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘abs_s’ ../basicOp_stl2005_v2.2/basop32.h:70: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘shl’ ../basicOp_stl2005_v2.2/basop32.h:71: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘shr’ . . . . . .

  • cygwinでgcc/g77が動かない

    vaioG/vista-business/2Gmemoryでcygwinを使っていましたが、g77/gccが動かなくなってしまいました。cygwinをuninstall、レジストリーを消してcygwinを入れ替えても同じです。たとえば、gcc a.c で 5508 init_cheap: Couldn't reserve 3600336 bytes of space for cygwin's heap, Win32 error 487 のメッセージがでて止まらなくなります。何かsystemのmemory設定が変わってしまったのでしょうか。vistaの再インストールをしても同じでした。 なお、cygwinの前にはminsysでgcc/g77を使っていましたが、このときもある時から急にgcc/g77がエラーになり、cygwinに切り替えた経緯があります。また、desktopのXp上でのcygwinでは過去このような経験はありません。 外出先で仕事ができない状態ですので、何か情報があればよろしくお願いします。

専門家に質問してみよう