问题描述
- C语言Macro替代错误(个人认为应该是Macro的问题)
- Fatal.h
#include
#include
#define Error(Str) FatalError(Str)
#define FatalError(Str) fprintf(stderr%sn"" Str)exit(1)
Test.c
#include
#include ""Fatal.h""int main(int argc char ** argv)
{
Error(""Test to be wrong"");
return 0;}
gcc 编译时报:
warning: format ‘%s’ expects a matching ‘char *’ argument [-Wformat=]
Error(""Test to be wrong"");^
求解答。
解决方案
#define FatalError(Str) fprintf(stderr%sn"" Str)exit(1)
不觉得这里少了一个吗?
#define FatalError(Str) fprintf(stderr%sn"" Str)exit(1)
时间: 2024-08-18 05:08:19