Doxygenのドキュメントとともに以下に示すように、好奇心を感じる関数を見つけたときにいくつかの解析を実行するC++ソースコードファイルを探していました。C++の関数引数リスト内の末尾のドット(...)
私の質問は、関数ERRORの引数で、末尾のドット(...)は何ですか? はどういう意味ですか?これが初めて使用されているのがわかります。私が使用
/**
* Create an error with given message id and fill in given string in message
* @PARAM row row where the error occured (0 to neglect)
* @PARAM col column where the error occured (0 to neglect)
* @PARAM id id of the message
* @PARAM arg an argument which will be filled in in the message,
* replacing %s, %i, %f, %c
*/
Error::Error(const int row, const int col, const int id, ...)
: err_row(row), err_col(col), err_id(id)
{
//sprintf(msg, msgdesc(id));
const char* msg_desc = msgdesc(id);
va_list args;
va_start(args, msg_desc);
vsnprintf(msg, sizeof(msg)-1, msg_desc, args);
msg[sizeof(msg)-1] = '\0';
va_end(args);
}
gcc
コンパイラが私をスロー可変長引数リストをある
parser_error.cpp: In constructor ‘Error::Error(int, int, int, ...)’:
parser_error.cpp:30: warning: second parameter of ‘va_start’ not last named argument
'int printf(char const *、...)' –
[正しい用語 "..."]の複製可能です。(http://stackoverflow.com/questions/4937454/correct-term-for) –
末尾の...は、関数内に可変数の引数があることを意味します。最初の3つの引数の中の何かが、それ以上の引数があるかどうかについてコンパイラに通知します。最も一般的な例は 'printf'です。 – twain249