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

歡迎訪問 生活随笔!

生活随笔

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

编程问答

宏定义宏函数 if else语句报错:error: ‘else’ without a previous ‘if’(看似解决实际上没解决)

發布時間:2023/12/31 编程问答 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 宏定义宏函数 if else语句报错:error: ‘else’ without a previous ‘if’(看似解决实际上没解决) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

代碼

#include <stdio.h> #include <stdlib.h>#define ALOGE(...) { printf(__VA_ARGS__); printf("\n"); }#define fprintf(x, ...) { if(x==stderr) ALOGE(__VA_ARGS__);else fprintf(x, __VA_ARGS__); }static void usage_tip(FILE *fp, int argc, char **argv) {fprintf(fp, "Usage: %s [options]\n""Version %s\n""Options:\n""-d | --debug Debug option\n""-n | --no-mediaserver without mediaserver\n""-h | --help For help \n""\n",argv[0], "V1.0"); }int main(int argc, char **argv) {usage_tip(stderr, argc, argv);return(0); }

ubuntu編譯時報錯

解決辦法

真見鬼,代碼應該是沒問題的,因為我是從RXWbrcm_patchram_plus1.c抄過來的

然后我在if語句的后一句代碼套上{}(或者去掉ALOGE(__VA_ARGS__);后的分號)就好了

#include <stdio.h> #include <stdlib.h>#define ALOGE(...) { printf(__VA_ARGS__); printf("\n"); }#define fprintf(x, ...) { if(x==stderr) {ALOGE(__VA_ARGS__);} else fprintf(x, __VA_ARGS__); }static void usage_tip(FILE *fp, int argc, char **argv) {fprintf(fp, "Usage: %s [options]\n""Version %s\n""Options:\n""-d | --debug Debug option\n""-n | --no-mediaserver without mediaserver\n""-h | --help For help \n""\n",argv[0], "V1.0"); }int main(int argc, char **argv) {usage_tip(stderr, argc, argv);return(0); }

編譯運行:

總結

以上是生活随笔為你收集整理的宏定义宏函数 if else语句报错:error: ‘else’ without a previous ‘if’(看似解决实际上没解决)的全部內容,希望文章能夠幫你解決所遇到的問題。

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