[英]Objective C and c++ import problem. Simple but I don't get it
我正在使用cocos2d和box2d。(iPhone SDK)如果我要導入box2d,我將它添加到文件#import“Box2D.h”的頂部,然后我將我的類重命名為“ .mm ”。 現在我只有一個沒有 “.m”文件的類只是一個“.h”文件。
它看起來像那樣,如果我導入box2d它給了我很多錯誤,因為box2d是c ++,通常我需要將它改為“.mm”,但我不能。
#import "Box2D.h"
// Defines individual types of messages that can be sent over the network. One type per packet.
typedef enum
{
kPacketTypeTime = 1,
kPacketTypePosition = 2,
kPacketTypeStartSignal = 3,
} EPacketTypes;
// Note: EPacketType type; must always be the first entry of every Packet struct
// The receiver will first assume the received data to be of type SBasePacket, so it can identify the actual packet by type.
typedef struct
{
EPacketTypes type;
} SBasePacket;
// the packet for transmitting a score variable
typedef struct
{
EPacketTypes type;
float time;
} STimePacket;
// packet to transmit a position
typedef struct
{
EPacketTypes type;
b2Vec2 position; //*******************************important**
float rotation;
} SPositionPacket;
// packet to transmit a start signal
typedef struct
{
EPacketTypes type;
BOOL startGame;
} SStartSignalPacket;
為什么我要這樣做? 查看我的代碼中的“ * * important”。 我想用b2Vec2。
非常感謝您的閱讀。 祝你今天愉快 :)
嘗試將標題重命名為.hh,因為編譯器仍將其視為目標C.
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.