CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

unions

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
alexz



Joined: 17 Sep 2004
Posts: 133
Location: UK

View user's profile Send private message

unions
PostPosted: Wed Feb 09, 2005 5:51 am     Reply with quote

I have got the following structure:

struct HostCBW
{
BYTE Signature[4];
BYTE Tag[4];
BYTE DataTransferLen[4];
BYTE CBWFlags; BYTE CBWLUN;
BYTE CBLength;
BYTE CBWCB[16];
};

And the following union:


union CommandBlockWrapper
{
struct HostCBW CBWField;
BYTE CBWBuffer[31];
}CBW;


How can I modify this union, to have the CBW.CBWField.CBWCB[0] to be at the same address as an additional byte variable?
In other words that I will be able to call this particular byte using a different name.
_________________
Alex
Charlie U



Joined: 09 Sep 2003
Posts: 183
Location: Somewhere under water in the Great Lakes

View user's profile Send private message

PostPosted: Wed Feb 09, 2005 7:38 am     Reply with quote

The structure and the array in the union are just overlapped. You can access the first byte of the union by using either

CBW.CBWBuffer[0]

or

CBW.CBWField.Signature[0].

The other bytes are just accessed similarly in the order that you have declared them.
alexz



Joined: 17 Sep 2004
Posts: 133
Location: UK

View user's profile Send private message

PostPosted: Wed Feb 09, 2005 7:42 am     Reply with quote

Charlie U wrote:
The structure and the array in the union are just overlapped. You can access the first byte of the union by using either

CBW.CBWBuffer[0]

or

CBW.CBWField.Signature[0].

The other bytes are just accessed similarly in the order that you have declared them.


Yeah, I know that.
What I mean is, you can use those two different names because thay are at the same address.
I want #define newname CBW.CBWField.Signature[0]
but the same way as in unions. to have another variable at the same address
_________________
Alex
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group