静态缺点和静态 [英] static cons and static

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

问题描述

你好


我正在编译一些C代码我有一个问题


如果我宣布


static const short a [2] =( - 1,3)


int main(.....)


短b;


b = a [0]我得到-1

b = a [1]我得到3


如果我声明w / o const


静态短a [2] =( - 1,3)


它没有继续工作...


听起来像ARM库没有初始化这些数据(编译好了)


一个想法?


谢谢

Hello

I am compiling some C code and I have an issue

If I declare

static const short a[2] = (-1, 3)

int main(.....)

short b;

b= a[0] I get -1
b= a[1] I get 3

If I declare w/o const

static short a[2] = (-1, 3)

It does not work any longer ...

Sound like the ARM libraries are not initializing these data (which compiles OK)

ANy idea?

Thanks

推荐答案

andy写道:

static const short a [2] =(-1,3)
int main(.....)

短b;

b = a [0]我得到-1
b = a [1]我得到3
如果我宣布w / o const

静态短a [2] = (-1,3)

它不再起作用了......

谢谢

static const short a[2] = (-1, 3)

int main(.....)

short b;

b= a[0] I get -1
b= a[1] I get 3

If I declare w/o const

static short a[2] = (-1, 3)

It does not work any longer ...

Thanks




你能来吗?请po这是一个演示这种行为的完整程序吗?

从clc的角度来看,这应该可行。


(可能是链接器问题,我看到过类似的事情发生了在

不同的平台上,因为链接器没有正确设置)


-

Thomas。



Can you please post a full program that demonstrates this behaviour?
From the clc perspective this should work.

(it might be linker issue, I have seen something similar happen on a
different platform because the linker was not properly set up)

--
Thomas.


andy写道:
你好

我正在编译一些C代码,我有一个问题

如果我宣布

静态const短a [2] =( - 1,3)

int main(.....)

短b;

b = a [0]我得-1
b = a [1]我得到3

如果我宣布w / o const

静态短a [2] =( - 1,3)

它不再起作用了......

听起来像ARM库一样没有初始化这些数据(编译好了)

任何想法?
Hello

I am compiling some C code and I have an issue

If I declare

static const short a[2] = (-1, 3)

int main(.....)

short b;

b= a[0] I get -1
b= a[1] I get 3

If I declare w/o const

static short a[2] = (-1, 3)

It does not work any longer ...

Sound like the ARM libraries are not initializing these data (which compiles OK)

ANy idea?




是的,但是我的想法仅适用于您所展示的内容,而不是您的实际代码。你所展示的是*不是*

你的代码 - 这很容易看到,因为它甚至不会编译
,更不用说了。我不想浪费我的时间

试图猜测你的代码*可能*看起来像什么,也不是你的b / b
通过建议那些你不会做的修复任何好处,因为他们

不适用于您的实际代码。


现在,如果您要发布实际代码而不是

半生不熟的释义,事情可能会有所不同。提示。


-
Er ****** ***@sun.com



Yes, but my "idea" pertains only to what you''ve shown
us and not to your actual code. What you''ve shown is *not*
your code -- that''s easy to see, because it will not even
compile, much less run. I don''t feel like wasting my time
trying to guess what your code *might* look like, nor yours
by suggesting fixes that won''t do you any good because they
don''t apply to your actual code.

Now, if you were to post the actual code rather than a
half-baked paraphrase, things might be different. Hint.

--
Er*********@sun.com


andy写道:
...
我是编译一些C代码,我有一个问题

如果我声明

static const short a [2] =( - 1,3)

int main(.....)

短b;

b = a [0]我得-1
b = a [1]我得到3


不,你不是。上面的代码甚至不会编译。发布实际代码。

...
任何想法?
...
...
I am compiling some C code and I have an issue

If I declare

static const short a[2] = (-1, 3)

int main(.....)

short b;

b= a[0] I get -1
b= a[1] I get 3
No, you don''t. The code above won''t even compile. Post real code.
...
ANy idea?
...




发布实际代码。你当前形式的问题毫无意义。


-

祝你好运,

Andrey Tarasevich



Post real code. Your question in its current form makes no sense.

--
Best regards,
Andrey Tarasevich


这篇关于静态缺点和静态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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