开发者

error:static_cast undeclared->Objective C

I was porting from cpp to Objective C.

Objective C:

[pPacket SetH开发者_开发百科eaderSequenceNumber:static_cast<char>(m_transmitSequenceNumber + ASCII_ZERO)];

cpp:

pPacket->SetHeaderSequenceNumber(static_cast <char>(m_transmitSequenceNumber + ASCII_ZERO));

error:static_cast undeclared.


objective-c is a superset of c, not c++ so static_cast is not supported in it. You can just use c-style cast:

[pPacket SetHeaderSequenceNumber:(char)(m_transmitSequenceNumber + ASCII_ZERO)];


Objective C is a superset of C not C++. static_cast is a C++ operator so Objective C cannot use this.

However there is Objective C++ which does understand C++. To use this rename your .m file to .mm and Xcode will compile this as Objective C++

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜