aliyun / aliyun-log-c-sdk

Aliyun LOG Producer for C/C++
Other
215 stars 74 forks source link

编译错误: error: macro expands to multiple statements [-Werror=multistatement-macros] #42

Closed DinoStray closed 4 years ago

DinoStray commented 4 years ago

gcc --version gcc (Ubuntu 9.3.0-10ubuntu2) 9.3.0

编译错误:

In file included from /work/soft/aliyun-log-c-sdk-0.1.2/src/aos_util.h:5,
                 from /work/soft/aliyun-log-c-sdk-0.1.2/src/log_http_cont.h:12,
                 from /work/soft/aliyun-log-c-sdk-0.1.2/src/log_http_cont.c:9:
/work/soft/aliyun-log-c-sdk-0.1.2/src/log_http_cont.c: In function 'log_create_http_cont':
/work/soft/aliyun-log-c-sdk-0.1.2/src/aos_string.h:16:5: error: macro expands to multiple statements [-Werror=multistatement-macros]
   16 |     (str)->len = (int)strlen(text); (str)->data = (char *) text
      |     ^
/work/soft/aliyun-log-c-sdk-0.1.2/src/log_http_cont.c:128:9: note: in expansion of macro 'aos_str_set'
  128 |         aos_str_set(&(_sts_token), stsToken);
      |         ^~~~~~~~~~~
/work/soft/aliyun-log-c-sdk-0.1.2/src/log_http_cont.c:127:5: note: some parts of macro expansion are not guarded by this 'if' clause
  127 |     if(stsToken != NULL)
      |     ^~
In file included from /work/soft/aliyun-log-c-sdk-0.1.2/src/aos_util.h:5,
                 from /work/soft/aliyun-log-c-sdk-0.1.2/src/log_http_cont.h:12,
                 from /work/soft/aliyun-log-c-sdk-0.1.2/src/log_http_cont.c:9:
/work/soft/aliyun-log-c-sdk-0.1.2/src/log_http_cont.c: In function 'log_create_http_cont_with_lz4_data':
/work/soft/aliyun-log-c-sdk-0.1.2/src/aos_string.h:16:5: error: macro expands to multiple statements [-Werror=multistatement-macros]
   16 |     (str)->len = (int)strlen(text); (str)->data = (char *) text
      |     ^
/work/soft/aliyun-log-c-sdk-0.1.2/src/log_http_cont.c:197:5: note: in expansion of macro 'aos_str_set'
  197 |     aos_str_set(&(_sts_token), stsToken);
      |     ^~~~~~~~~~~
/work/soft/aliyun-log-c-sdk-0.1.2/src/log_http_cont.c:196:5: note: some parts of macro expansion are not guarded by this 'if' clause
  196 |     if(stsToken != NULL)
      |     ^~
shabicheng commented 4 years ago

45 fixed