Pulse union sigval value;

Hi Community !!

the structure pulse ist defined as follows:

struct _pulse {
_Uint16t type;
_Uint16t subtype;
_Int8t code;
_Uint8t zero[3];
union sigval value;
_Int32t scoid;

and I want to make an assignment like this

          struct _pulse pulse;

              something important

this never works.
please give me an solution for this member to do this.

Thank you !!!

Value is a union, what you are doing is exactly like trying to do

struct test {
int i;
int b;

struct test mytest;

if ( mytest ==1 ) // would you expect this to work ;-)

Yes; if this were C++ and there were a header file (not shown) that included the following definition:

bool operator==(struct test &lh, int rh)
return (lh.i == rh);


Thank you mario and rgallen

no I’dont expect this to work
I’ve only try to make my problem viewable with bad englisch
so, this is the easiest way to do this.

But how to get access to the pulse value to
print a text message with switch case like
pulse value =1 pritnts Message: xyz
pulse value =2 prints Message: zyx
and so on. ???

Thank you

struct _pulse pulse;

if(pulse.value.sigint ==1 )
something important
else if(pulse.value.sigint ==2 )
something even more important

Thank you mario great this works!

I’ve look the header signal.h where the sival union is defined.


Or you can write a C++ pulse class ;-) To be able to do

if ( pulse == 1 )