在我的程序中,我把這個代碼用於指示程序產生一個命令。這可以用來在我的程序中使用一個鍵啓動另一個程序,比如產生firefox。使用程序命令run_command「firefox」將有程序調用系統(「firefox &」)。警告:忽略'系統'的返回值c
case RUN_COMMAND:
if(arg) {
char commandline[ 256 ];
snprintf(commandline, sizeof (commandline), "%s &", arg);
if(cmd->screen) {
char message[ 256 ];
snprintf(message, sizeof (message), _("Running: %s"), arg);
screen_show_message(cmd->screen, message);
}
system(commandline);
}
break;
當我編譯它給這個錯誤:
warning: ignoring return value of 'system', declared with attribute warn_unused_result [-Wunused-result]
這不是一個錯誤;它是一個*警告*(這就是爲什麼它被稱爲「警告」,而不是「錯誤」。)你的問題是什麼? – 2012-02-05 15:23:53
可能重複[聲明屬性warn_unused_result \ [ - Wunused-result \]] (http://stackoverflow.com/questions/9148134/declared-with-attribute-warn-unused-result-wunused-result) – 2012-02-05 15:47:28