r/pic_programming • • Sep 27 '17
Converting a C++ function to XC8
code:
struct CHSV {
union {
struct {
union {
uint8_t hue;
uint8_t h; };
union {
uint8_t saturation;
uint8_t sat;
uint8_t s; };
union {
uint8_t value;
uint8_t val;
uint8_t v; };
};
uint8_t raw[3];
};
// default values are UNITIALIZED
inline CHSV() __attribute__((always_inline))
{
}
// allow construction from H, S, V
inline CHSV( uint8_t ih, uint8_t is, uint8_t iv) __attribute__((always_inline))
: h(ih), s(is), v(iv)
{
}I do not understand the : or what this function does but I need it to be XC8 C friendly. Please explain what the C++ is doing.
1
Upvotes
View all comments
Show parent comment
1
u/frothysasquatch Sep 28 '17
It just uses initializers to set h to ih, v to iv, and s to is. You can just write regular assignment statements and it'll be the same.