c const_cast的等价? [英] c equivalence of const_cast?

查看:51
本文介绍了c 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屋!

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