Skip to main content
GameDev.net gamedev.net
🔒 Locked

structure woes

Started by evilchicken Dec 2, 2001 at 6:07 PM 3 replies 900+ views
Original Post
evilchicken
evilchicken
this is just so very wierd this is what I have
    
#pragma pack(1)

typedef unsigned char byte;
typedef struct
{
	byte	type,
		packetid,
		pad,
		clientid;

	char	name[32];
}t_packet_cl_rename;
#pragma pack(0)
  
the third byte of this structure is locked with a value of 255, I cannot assign it a new value, it stays locked at 255. if I didnt have pad in there, clientid would be messed. what is going on? Edited by - evilchicken on December 3, 2001 1:23:10 PM
Succinct
Succinct
If you''re working with limited memory, doing transmissions or interpreting file headers, the packing is necessary, but otherwise it is not. Chicken probably knows that

But, yes - you do have to switch your typedef around.

-typedef unsigned char byte;-

-- Succinct

-- Succinct(Don't listen to me)
evilchicken
evilchicken
sorry, that was a typo on my part the problem remains
Skulver
Skulver
I would guess that whatever data you are reading from has the extra padding byte in there and that your data structure is if fact working correctly. What exactly do you mean that the 3rd byte is locked to 255? can you do a x.pad = 220 if you wish?
Other than that the only thing I can think of is that pack(0) looks strange, in VC++ you should be using #pragma pack(push, 1)
and #pragma pack(pop) when you are finished, though you are probably just using a different compiler

Eamonn.


Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.