首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

今天编程的时候发现一个有关问题,有坏的存储类

2013-02-19 
今天编程的时候发现一个问题,有坏的存储类今天编译的时候发现了一个以前没见过的问题,warning C4042: “iCo

今天编程的时候发现一个问题,有坏的存储类
今天编译的时候发现了一个以前没见过的问题,warning C4042: “iCount”: 有坏的存储类,我的iCount是接收其他函数产生的Gettickcount的值,我声明的iCount类型是static int,原因是什么?一般怎样改正?如果不改正将带来什么后果呢?刚才看了看msdn上的解释不太明白,希望高人赐教
[解决办法]
第三个错误:warning C4042: “xxxx” : 有坏的存储类
函数的参数.h与.cpp类型不同
[解决办法]
编译器警告(等级 1)C4042


“identifier”: 有坏的存储类
在此上下文中,指定的存储类不能与该标识符一起使用。 编译器改用默认的存储类:
extern (如果 identifier 是函数)。
auto(如果 identifier 是形参或局部变量)。
无存储类(如果 identifier 是全局变量)。
当在参数声明中指定 register 之外的存储类时便会出现此警告。
下面的示例生成 C4042
// C4042.cpp
// compile with: /W1 /LD
int func2( __declspec( thread ) int tls_i )    // C4042
// try the following line instead
// int func2( int tls_i )
{
   return tls_i;
}

http://msdn.microsoft.com/zh-cn/library/z9d31kt4(v=vs.100).aspx
[解决办法]
仅供参考:
Compiler Warning (level 1) C4042
'identifier' : has bad storage class

The storage class specified for the identifier could not be used in this context.

A default storage class for this context was used in place of the illegal storage class. Only the register storage class can be specified in a parameter declaration. The storage class was selected using the following rules. 

If the identifier was a function, the compiler assumed extern class.


If the identifier was a formal parameter or local variable, the compiler assumed auto class.


If the identifier was a global variable, the compiler assumed the variable was declared with no storage class. 

热点排行