Redian新闻
>
c++ does not check const for extern variable?
avatar
s*y
2
夕阳下我们俩
你带我去看的
天涯海角的夕阳
那么火红的海天一片
我从没见过
我拉着你的手
笑着看你
你的小眼睛
迷成一条线
闪着光亮
我怎么知道
还有这样的景色
如果你从未带我来
我怎么知道
还有这样的幸福
如果你从未出现
avatar
h*k
3
快不快?我就拿它当GPS用。
avatar
r*y
4
//1.cpp
extern const int i = 1;
//2.cpp
#include
using namespace std;
extern int i;
int main(){
i = 2;
cout <}
Nothing wrong to compile but segmentation fault when running
avatar
l*d
6
赞!!
avatar
s*e
7
很不错啊。
俺装了tomtom7和iGO8,
tomtom非常之稳定,iGO有时候会跳出来。

【在 h*k 的大作中提到】
: 快不快?我就拿它当GPS用。
avatar
p*o
8
I got a linking error:
>cl 1.cpp 2.cpp /EHsc
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.30319.01 for 80
x86
Copyright (C) Microsoft Corporation. All rights reserved.
1.cpp
2.cpp
Generating Code...
Microsoft (R) Incremental Linker Version 10.00.30319.01
Copyright (C) Microsoft Corporation. All rights reserved.
/out:1.exe
1.obj
2.obj
2.obj : error LNK2019: unresolved external symbol "int i" ([email protected]@3HA) referenc
ed in function _main
1.exe : fatal error LNK1120: 1 unresolved externals

【在 r*******y 的大作中提到】
: //1.cpp
: extern const int i = 1;
: //2.cpp
: #include
: using namespace std;
: extern int i;
: int main(){
: i = 2;
: cout <: }

avatar
s*t
10
^_^,真甜啊。加一个积分
avatar
h*k
11
谢谢。如果就当GPS用的话,多大的SD卡就够用了啊?

【在 s******e 的大作中提到】
: 很不错啊。
: 俺装了tomtom7和iGO8,
: tomtom非常之稳定,iGO有时候会跳出来。

avatar
r*y
12
g++ -o 2 2.cpp 1.cpp
it is ok in this way to compile

80

【在 p***o 的大作中提到】
: I got a linking error:
: >cl 1.cpp 2.cpp /EHsc
: Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.30319.01 for 80
: x86
: Copyright (C) Microsoft Corporation. All rights reserved.
: 1.cpp
: 2.cpp
: Generating Code...
: Microsoft (R) Incremental Linker Version 10.00.30319.01
: Copyright (C) Microsoft Corporation. All rights reserved.

avatar
L*o
13
赞,幸福啊。

【在 s*******y 的大作中提到】
: 夕阳下我们俩
: 你带我去看的
: 天涯海角的夕阳
: 那么火红的海天一片
: 我从没见过
: 我拉着你的手
: 笑着看你
: 你的小眼睛
: 迷成一条线
: 闪着光亮

avatar
s*e
14
2G足够乐。

【在 h*k 的大作中提到】
: 谢谢。如果就当GPS用的话,多大的SD卡就够用了啊?
avatar
p*o
15
Good to know. Then we need someone to dig the standard to see
whether g++ is not conforming or VC is doing something extra.

【在 r*******y 的大作中提到】
: g++ -o 2 2.cpp 1.cpp
: it is ok in this way to compile
:
: 80

avatar
i*s
16
赞!
avatar
h*t
17
挺好的,尽管CPU不是很快,如果愿意琢磨的话,可以自己做nk.bin,甚至可以改造成
WM5的PDA.
avatar
t*t
18
3.5 [Program and Linkage]
10 After all adjustments of types (during which typedefs (7.1.3) are
replaced by their definitions), the types specified by all declarations
referring to a given object or function shall be identical, except that
declarations for an array object can specify array types that differ by the
presence or absence of a major array bound (8.3.4). A violation of this rule
on type identity does not require a diagnostic.

【在 p***o 的大作中提到】
: Good to know. Then we need someone to dig the standard to see
: whether g++ is not conforming or VC is doing something extra.

avatar
l*e
19
cpu是233的,硬伤,如果也是400的cpu,这价格,无敌了!
avatar
P*e
20
const implies local linkage
extern means external linkage
combining them together won't work.
Solution:
define: const int i = 1; in every compilation unit, and linker will merge
the duplicates.
It has the same effect as extern const.

【在 r*******y 的大作中提到】
: //1.cpp
: extern const int i = 1;
: //2.cpp
: #include
: using namespace std;
: extern int i;
: int main(){
: i = 2;
: cout <: }

avatar
J*3
21
要折腾得化,最好4G。

【在 s******e 的大作中提到】
: 2G足够乐。
avatar
t*t
22
typical PaulPierce c++ post: it's hard to find a correct statement.
const implies INTERNAL linkage (not local linkage, there is no such thing as
"local linkage") IF it is not declared extern. [3.5, 3]
extern const int c = 1;
is explicitly allowed by standard. it is even in the example. [3.1, 3] so
combining extern and const WILL work.
defining const int i=1 in every compilation unit is fine. however, linker
will NOT merge them, because each "const int i=1" has internal linkage and
they shall NOT be merged. in fact, most probably linker will NOT see this
symbol exported at all. and it does NOT has the same effect as extern const,
because in each compilation unit, the address of i is not the same. (most
probably you won't use the address, of course.)
any questions?

【在 P********e 的大作中提到】
: const implies local linkage
: extern means external linkage
: combining them together won't work.
: Solution:
: define: const int i = 1; in every compilation unit, and linker will merge
: the duplicates.
: It has the same effect as extern const.

avatar
hs
23
各种折腾也超不过 2G 吧:-)
话说现在折腾最多的是那种玩法?

【在 J********3 的大作中提到】
: 要折腾得化,最好4G。
avatar
M*t
24
You are right
Automatic (local) variables exist only temporarily, on the stack, while a
function is being called. The linker doesn’t know about automatic variables
, and so these have no linkage.

as

【在 t****t 的大作中提到】
: typical PaulPierce c++ post: it's hard to find a correct statement.
: const implies INTERNAL linkage (not local linkage, there is no such thing as
: "local linkage") IF it is not declared extern. [3.5, 3]
: extern const int c = 1;
: is explicitly allowed by standard. it is even in the example. [3.1, 3] so
: combining extern and const WILL work.
: defining const int i=1 in every compilation unit is fine. however, linker
: will NOT merge them, because each "const int i=1" has internal linkage and
: they shall NOT be merged. in fact, most probably linker will NOT see this
: symbol exported at all. and it does NOT has the same effect as extern const,

avatar
n*g
25
我加新的 Navigon,必須把所有的其他軟件刪除干凈才夠
剩余空間還有 2M

【在 hs 的大作中提到】
: 各种折腾也超不过 2G 吧:-)
: 话说现在折腾最多的是那种玩法?

avatar
w*m
26
......I loaded tomtom, amigo, garmin, navigon in a 2GB sd card.

【在 n****g 的大作中提到】
: 我加新的 Navigon,必須把所有的其他軟件刪除干凈才夠
: 剩余空間還有 2M

avatar
n*g
27
新的 2009Q1 navigon 地圖就將近 2G 了

【在 w*m 的大作中提到】
: ......I loaded tomtom, amigo, garmin, navigon in a 2GB sd card.
avatar
l*e
28
igo,tomtom,navigon,amigo,garmin都可以用单独的州地图
但是,还是全国制霸,还要加上加拿大,虽然没机会去
我合计再下个欧洲的,16g卡,半个世界都差不多够了

【在 n****g 的大作中提到】
: 新的 2009Q1 navigon 地圖就將近 2G 了
avatar
w*m
29
load your state map only.

【在 n****g 的大作中提到】
: 新的 2009Q1 navigon 地圖就將近 2G 了
avatar
J*3
30
问题是你知道如何把1.7G的地图分解开,然后找到需要的吗?
Garmin的地图倒是可以分解,可费了半天劲分解100多块了,不会找需要的state map,
google了一圈也没找到那些数字如何对应各州。
大虾出手指点一下如何?

【在 w*m 的大作中提到】
: load your state map only.
avatar
J*3
31
好用不?那个1.7G的地图文件包括POI,Terrain吗?

【在 n****g 的大作中提到】
: 我加新的 Navigon,必須把所有的其他軟件刪除干凈才夠
: 剩余空間還有 2M

avatar
J*3
32
一张卡放几种程序和地图,我现在弄了3张2G卡玩,两张比较固定,一张用来做试验。

【在 hs 的大作中提到】
: 各种折腾也超不过 2G 吧:-)
: 话说现在折腾最多的是那种玩法?

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。