c const_cast的等价? [英] c equivalence of const_cast?
问题描述
我正在尝试将一小段c ++代码转换为c,只是为了简化
将它连接到第三种语言(我不知道c或/ >
c ++)。
什么是c等价:
lpData = const_cast< char *>(Something);
尝试使用gcc 3.2.3编译(mingw special 20030504-1)
谢谢!
Bj ?
我不是c ++大师,但我认为你应该可以这样做:
lpData =(const char *)something;
" Mike Deskevich" < MI *********** @ gmail.com>写道:我不是c ++大师,但我认为你应该能做到:
lpData =(const char *)something;
实际上,我认为他想要
lpData =(char *)的东西;
< OT>
C ++ const_cast用于抛弃constness。 C ++有几种类型的演员阵容比C'更受限制只需转换它,
相信我,我知道我在做什么投。 (C ++有C风格的演员阵容
很好。)
< / OT>
-
Keith Thompson(The_Other_Keith) ks***@mib.org < http://www.ghoti.net/ ~kst>
圣地亚哥超级计算机中心< *> < http://users.sdsc.edu/~kst>
我们必须做点什么。这是事情。因此,我们必须这样做。
" Bj?rn" < SS ***** @ hotmail.com>在消息中写道
新闻:d5 ************************* @ posting.google.co m ... < blockquote class =post_quotes>我正在尝试将一小段c ++代码转换为c,只是为了轻松将其链接到第三种语言(我不知道c或者/ > c ++)。
什么是c等价:
lpData = const_cast< char *>(Something);
lpData =(char *)Something;
(C与C ++没有不同的'''''''''''''。
>
-Mike
I''m trying to convert some small piece of c++ code to c, only to ease
linking it to a third language (I''m not knowledgeable in either c or
c++).
What would be the the c equivalence of:
lpData=const_cast<char*>(Something);
Trying to compile this with gcc 3.2.3 (mingw special 20030504-1)
Thanks!
Bj?rn
i''m not a c++ guru, but i think you should be able to do:
lpData=(const char*)something;
"Mike Deskevich" <mi***********@gmail.com> writes:i''m not a c++ guru, but i think you should be able to do:
lpData=(const char*)something;
Actually, I think he wants
lpData = (char*)something;
<OT>
A C++ const_cast is used to cast away constness. C++ has several
flavors of casts that are more restricted than C''s "Just convert it,
trust me, I know what I''m doing" cast. (C++ has C-style casts as
well.)
</OT>
--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
"Bj?rn" <ss*****@hotmail.com> wrote in message
news:d5*************************@posting.google.co m...I''m trying to convert some small piece of c++ code to c, only to ease
linking it to a third language (I''m not knowledgeable in either c or
c++).
What would be the the c equivalence of:
lpData=const_cast<char*>(Something);
lpData = (char*)Something;
(C doesn''t have different ''flavors'' of casts as does C++.)
-Mike
这篇关于c const_cast的等价?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!