Jump to content

Must Use S->v Not (*s).v When Writing To A Struct Member

Recommended Posts

Hi there,


boostc V7.01



Please see comments in the code below:


#include <system.h>


typedef struct {

unsigned char bitfield1;

unsigned char bitfield2;

unsigned char bitfield3;

} TTestStruct;


TTestStruct s;


void SetAVal(TTestStruct *ps)


//This doesn't work because *ps gets copied into a temp variable

//which never gets copied back.

(*ps).bitfield3 = 5;


//This works

ps->bitfield3 = 5;



void main(void)








Andy Leiper


Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...