数组未定义为静态的问题 [英] Problem with array not defined as static

查看:76
本文介绍了数组未定义为静态的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在控制台应用程序上使用VC ++ 2015 Express。  这是C代码,而不是C ++,因此不使用类。

I am using VC++ 2015 Express on a console application.  This is C code, not C++, so not classes are in use.

我有一个数组或指向文件顶部定义的结构的指针。

I have an array or pointers to structs defined at the top of the file.

静态MYSTRUCT *      myarray [16]; 

static MYSTRUCT*       myarray[16]; 

我现在想把代码分解成3个文件,所以我需要删除静态代码。  当我删除静态时,仍然使用原始代码,代码不再有效。

I now want to break the code the code into 3 files so I need to remove the static.  When I remove the static, still with the original code, the code no longer works.

MYSTRUCT *      myarray [16]; 

MYSTRUCT*       myarray[16]; 

如果我在myarray上设置一个监视器,我可以看到它在没有被使用时损坏了。  我尝试过使用大型简单数组或字符的类似测试,同样的事情发生了。  必须将其声明为静态。

If I set a watch on myarray, I can see it corrupt when it is not being used.  I have tried a similar test with a large simple array or chars and the same thing happens.  It has to be declared static.

这是错误还是操作员错误?

Is this a bug or operator error?

Scott

推荐答案

很难说不知道你如何使用它。

Hard to say without knowing how you use it.

我测试时间相当短应用程序和我放入数组的内容是打印值时数组中出现的内容。我特意避免在保持应用程序工作的同时触摸那个内存,无论我浪费多长时间,
甚至不断从其他地方访问内存,数组内容都很好。

I tested out with a fairly short application and what I put into the array is what comes out of the array when I print the values. I purposely avoid touching that memory while keeping the application working on something, and no matter how long I waste time, even constantly accessing memory from elsewhere, the array contents are fine.

因此,请提供更多信息,包括尽可能少的样本。

So please give more information, including a small sample if possible.


这篇关于数组未定义为静态的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆