__FUNCTION__ predefined macro cannot appear outside of a function body
2016-09-26 16:17
260 查看
在Visual Studio 2005中,默认情况下,此特性是激活的,但不能与/EP和/P编译选项同时使用。请注意在IDE环境中,不能识别__func__ ,而要用__FUNCTION__ 代替。
Comeau的用户也应使用 __FUNCTION__ ,而不是 __func__ 。
C++ BuilderX的用户则应使用稍稍不同的名字:__FUNC__ 。
GCC 3.0及更高的版本同时支持 __func__ 和__FUNCTION__ 。
可自动获取当前函数名。
QT :调整一下头文件的顺序就OK了 ? Not。
#define Show(a) MyShow(a, __FUNCTION__) //避免了重定义的问题! 要把它包起来
void MyShow(int size, char *path="")
{
printf("This fake error is in [ %s ] on line [%d]\n", path, __LINE__);
}
VS : #include "stdafx.h"
Comeau的用户也应使用 __FUNCTION__ ,而不是 __func__ 。
C++ BuilderX的用户则应使用稍稍不同的名字:__FUNC__ 。
GCC 3.0及更高的版本同时支持 __func__ 和__FUNCTION__ 。
可自动获取当前函数名。
QT :调整一下头文件的顺序就OK了 ? Not。
#define Show(a) MyShow(a, __FUNCTION__) //避免了重定义的问题! 要把它包起来
void MyShow(int size, char *path="")
{
printf("This fake error is in [ %s ] on line [%d]\n", path, __LINE__);
}
VS : #include "stdafx.h"
相关文章推荐
- Cannot assign to 'self' outside of a method in the init family
- 关于error:Cannot assign to 'self' outside of a method in the init family
- BUG:Cannot return from outside a function or method
- Cannot yield a value in the body of a try block with a catch clause
- cannot pass non-trivial object of type 'string' to variadic function
- 报错:Cannot return from outside a function or method
- jsp网页出现“Cannot return from outside a function or method”
- Cannot return from outside a function or method
- Cannot return from outside a function or method
- 关于error:Cannot assign to 'self' outside of a method in the init family
- 关于error:Cannot assign to \'self\' outside of a method in the init family
- 【报错】Cannot return from outside a function or method
- Cannot assign to 'self' outside of a method in the init family
- Cannot find the definition(implementation) of this function
- 关于error:Cannot assign to 'self' outside of a method in the init family
- Cannot find the definition (implementation) of this function
- Cannot return from outside a function or method 解决方案
- 关于error:Cannot assign to 'self' outside of a method in the init family
- 怎样去除JSP页面提示:Cannot return from outside a function or method.
- Cannot assign to 'self' outside of a method in the init family