safememset

Technical questions regarding the XTC tools and programming with XMOS.
Post Reply
zog
Junior Member
Posts: 4
Joined: Tue Mar 20, 2012 11:59 pm

safememset

Post by zog »

Hello,

I have a big struct which I want to set to 0 however I am not able to use the safememset
on that struct, I can only use it with chars. Is there a way to use safememset on a struct?


richard
Respected Member
Posts: 318
Joined: Tue Dec 15, 2009 12:46 am

Post by richard »

You can use a reinterpret cast to interpret the struct as an array of chars and then use that as an argument to safememset(). For example:

Code: Select all

struct foo s;
safememset((s, char[]), 0, sizeof(s));
zog
Junior Member
Posts: 4
Joined: Tue Mar 20, 2012 11:59 pm

Post by zog »

Thanks Richard, that was exactly what I was looking for.
Post Reply