一週間前に、動作しなかったコードでgetlineという関数を作成しました。それ以来、関数のgetlineに名前を付けてコンパイルしようとすると、関数は動作しません。関数の名前を何かに変更すると、関数は再び機能します。私は自分のコンピュータを再起動しましたが(本当に必要ないはずですが)。この名前空間を戻すにはどうしたらいいですか?コンパイラはその名前空間にスタックされた関数を持っています(おそらく?)。 mac
例エラーメッセージ:
Numens-MBP:c examples mycotic$ cc testing.c
testing.c:9:5: error: conflicting types for 'getline'
int getline(void);
^
/usr/include/stdio.h:448:9: note: previous declaration is here
ssize_t getline(char ** __restrict __linep, size_t * __restrict __lineca...
^
testing.c:13:1: warning: type specifier missing, defaults to 'int'
[-Wimplicit-int]
main()
^
testing.c:20:24: error: too few arguments to function call, expected 3, have 0
while ((len = getline()) > 0)
~~~~~~~^
/usr/include/stdio.h:448:1: note: 'getline' declared here
ssize_t getline(char ** __restrict __linep, size_t * __restrict __lineca...
^
testing.c:36:5: error: conflicting types for 'getline'
int getline(void)
^
/usr/include/stdio.h:448:9: note: previous declaration is here
ssize_t getline(char ** __restrict __linep, size_t * __restrict __lineca...
^
1 warning and 3 errors generated.
"getline"を関数名として使用することは以前には有効でしたか? 「それは働いた」と「もう働かない」の間に何が起こったのですか?プラットフォームの切り替え?コンパイラのスイッチ?ヘッダー(場所、命名)について何か変更しますか? – Yunnosch
以前の 'getline'関数の使用では、Windows(または他のPOSIX以外のシステム)上のどこですか?または、C++をプログラミングしていましたか? –