日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

C: warning: too many arguments for format [-Wformat-extra-args]

發布時間:2023/12/18 编程问答 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 C: warning: too many arguments for format [-Wformat-extra-args] 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

文章目錄

  • 警告
  • 代碼
  • 原因
  • 另外一例
  • gcc 編譯器相關的代碼

警告

cc1: warning: -Wformat-extra-args ignored without -Wformat [-Wformat-extra-args]

代碼

gcc -Wformat-extra-args timer.c

printf(“handler set timerout=1\n”, “abc”); 、、、后面這個 “abc”多余,或者 前面的少了%s;

原因

這個警告的原因是,format里沒有%s,但是卻傳進來一個 常量字符串,給format。

另外一例

%z是標識size_t的一個說明符,但是數據類型還是要在后面跟著: %zu;
sizeof.c:10:9: warning: too many arguments for format [-Wformat-extra-args]
printf(“sizeof(double)=%z\n”, sizeof(double));

gcc 編譯器相關的代碼

gcc/c-family/c-format.c

/* If there were extra arguments to the format, normally warn. However,the standard does say extra arguments are ignored, so in the specificcase where we have multiple leaves (conditional expressions orngettext) allow extra arguments if at least one leaf didn't have extraarguments, but was otherwise OK (either non-literal or checked OK).If the format is an empty string, this should be counted similarly to thecase of extra format arguments. */if (res.number_extra_args > 0 && res.number_non_literal == 0&& res.number_other == 0){if (res.extra_arg_loc == UNKNOWN_LOCATION)res.extra_arg_loc = loc;warning_at (res.extra_arg_loc, OPT_Wformat_extra_args,"too many arguments for format");}

總結

以上是生活随笔為你收集整理的C: warning: too many arguments for format [-Wformat-extra-args]的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。