|
发表于 2018-3-14 17:39:55
|
显示全部楼层
本帖最后由 人造人 于 2018-3-14 17:41 编辑
这是C语言,你用的是C++的环境吧?
- sh-4.4$ ls
- main.c
- sh-4.4$ cat main.c
- #include <stdio.h>
- #include <math.h>
- #define PR(X,...) printf("Message " #X " : "__VA_ARGS__)
- int main(void)
- {
- double x=40;
- double y;
- y=sqrt(x);
- PR(1,"x =%g\n",x);
- PR(2,"x=%.2f,y=%.4f\n",x,y);
- return 0;
- }
- sh-4.4$ gcc main.c
- sh-4.4$ ls
- a.exe main.c
- sh-4.4$ rm a.exe
- sh-4.4$ mv main.c main.cpp
- sh-4.4$ ls
- main.cpp
- sh-4.4$ g++ main.cpp
- main.cpp: In function 'int main()':
- main.cpp:3:40: error: unable to find string literal operator 'operator""__VA_ARGS__' with 'const char [13]', 'long unsigned int' arguments
- #define PR(X,...) printf("Message " #X " : "__VA_ARGS__)
- ^
- main.cpp:9:9: note: in expansion of macro 'PR'
- PR(1,"x =%g\n",x);
- ^~
- main.cpp:3:40: error: unable to find string literal operator 'operator""__VA_ARGS__' with 'const char [13]', 'long unsigned int' arguments
- #define PR(X,...) printf("Message " #X " : "__VA_ARGS__)
- ^
- main.cpp:10:9: note: in expansion of macro 'PR'
- PR(2,"x=%.2f,y=%.4f\n",x,y);
- ^~
- sh-4.4$
复制代码 |
|