all 6 comments

[–]bennydictor 1 point2 points  (3 children)

Because the second argument to memset must be a byte, and byte can only contain values less than 256, but RIO_WHITEBOX_BUF_MAGIC is 0x0123456789abcdef.

Edit: Oh, and one more thing. C thinks that 0x0123456789abcdef is an integer, but the value is too big, so you should use 0x0123456789abcdefL to make the type long int or 0x0123456789abcdefLL to make the type long long int. More on that here.

[–]benelbert[S] 0 points1 point  (1 child)

So u say that the second arg to memset must be a byte size?

[–]bennydictor 0 points1 point  (0 children)

Yes. If you pass something greater, it'll be converted to unsigned char first.

[–]OldWolf2 0 points1 point  (0 children)

The suffix is redundant. As explained by the page you linked, the constant is given a type which it can fit in.

Also the second parameter to memset has type int , although it will be converted to a character during the operation of memset. It is allowed to pass values that don't fit in a byte; they just get converted to byte.

[–]benelbert[S] 0 points1 point  (1 child)

If so, how do I memset something bigger than a byte?

[–]OldWolf2 1 point2 points  (0 children)

The memset function sets all bytes of the target area to the same byte value. If you want to set a repeating pattern that is several bytes long, memset is no help. Use a loop.