关于gcc的警告:warning: useless keyword or type name in empty declaration
2011-09-27 21:58
1511 查看
如果你在c文件里面定义:
static struct my_struct
{
。。。
};
则会报这个警告,去除该警告有2种方法:
(1)把static去掉:
struct my_struct
{
。。。
};
定义变量时加上static,例如static struct my_struct my_val;
(2)在定义时加上变量:
static struct my_struct
{
。。。
}my_val;
显然,这是修饰符的问题。用上static后,它修饰的是变量,但struct xxx{};只是一个类型而已。所以说类型是不需要static的,这就是方法一的实现。另外如果struct定义后面加上变量以后,那么这个static就是修饰的这个变量,警告也就没了,这也是方法二的实现。
static struct my_struct
{
。。。
};
则会报这个警告,去除该警告有2种方法:
(1)把static去掉:
struct my_struct
{
。。。
};
定义变量时加上static,例如static struct my_struct my_val;
(2)在定义时加上变量:
static struct my_struct
{
。。。
}my_val;
显然,这是修饰符的问题。用上static后,它修饰的是变量,但struct xxx{};只是一个类型而已。所以说类型是不需要static的,这就是方法一的实现。另外如果struct定义后面加上变量以后,那么这个static就是修饰的这个变量,警告也就没了,这也是方法二的实现。
相关文章推荐
- 关于gcc的警告:warning: useless keyword or type name in empty declaration
- Warning -26490: File name in a multipart submit is missing or empty.解决方法
- 转:Warning -26490: File name in a multipart submit is missing or empty.解决方法
- 解决gcc的error: useless storage class specifier in empty declaration
- The type or namespace name 'Windows' does not exist in the namespace....
- 关于OPENCV The node is neither a map nor an empty collection in function cvGetFileNodeByName
- 关于警告: No mapping found for HTTP request with URI [/spMVC/] in DispatcherServlet with name 'spMVC'的问题
- The type or namespace name 'Windows' does not exist in the class or namespace 'System'
- Error:The type or namespace name 'Office' does not exist in the namespace 'Microsoft' 解决方法
- 关于Notice: Use of undefined constant username - assumed 'username' in警告问题
- 关于解决keil编程调试过程中的警告warning: #1295-D: Deprecated declaration KEY_Init - give arg types
- Illegal offset type in isset or empty in in project
- gcc下编译出现warning:implicit declaration of function 'strdup'和warning:implicit declaration of function 'gethostname'
- (GCC) Warning: 'typedef' was ignored in this declaration
- [EntLib]解决The type or namespace name 'Data' does not exist in the namespace 'Microsoft.Practices.EnterpriseLibrary' 的错误
- this declaration has no storage class or type specifier。。。警告什么意思
- Compiler Error Message: CS0234: The type or namespace name 'BorderDetails' does not exist in the class or namespace 'Infragistics.WebUI.Shared' (are you missing an assembly reference?)
- The type or namespace name 'Zhaopin' does not exist in the namespace 'LMSoft' 问题的解决
- The type or namespace name 'AjaxControlToolkit' could not be found in the global namespace
- CS0234 The type or namespace name 'Mvc' does not exist in the namespace 'Microsoft.AspNet' (are you