Objective C and c++ import problem. Simple but I don't get it
I'm using cocos2d and box2d.(iPhone SDK) If I want to import box2d I add this to the top of the file #import "Box2D.h" and then I rename my class to ".mm". Now I have just a class without a ".m" file just a ".h" file.
It looks like that and if I import box2d it gives me many errors because box2d is c++ and normally i need to change it to ".mm" but i cant.
#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;
Why I want to do this? Look at the "**important" in my code. I want to use b2Vec2.
Thank you very much for reading. Have a nice day :)
Try to rename header to .hh, cause compiler still treats it as Objective C
精彩评论