imneme / pcg-c-basic

PCG — Minimal C Implementation
Apache License 2.0
408 stars 51 forks source link

C4146 in VS 2013 #10

Open zno5 opened 7 years ago

zno5 commented 7 years ago

uint32_t pcg32_random_r(pcg32_random_t* rng);

I got an error message C4146 when I compiled this function with vs 2013. the problem is the minus op applied to unsigned type variable rot(in the return code).

Could you change that code like ~rot + 1 instead of -rot.

thanks.

and I think this following issue is minor... I think xorshifted variable would need a casting op. like this uint32_t xorshifted = (uint32_t) (((oldstate >> 18u) ^ oldstate) >> 27u);

Srekel commented 7 years ago

Same here with VS2017. Could "fix" it by adding

pragma warning( disable : 4146 )

But zno5's solution might be better.

lemire commented 7 years ago

The question is whether the warning is legitimate as per the language specification.