[ros-dev] [ros-diffs] [sginsberg] 43167: - HAL: Make /W3 friendly - Everywhere else: Use casts instead of -1U to fix C4146 (this is compatible with both compilers)

Timo Kreuzer timo.kreuzer at web.de
Sat Sep 26 20:23:34 CEST 2009


But that doesn't work with ULONG_PTR, unless you want to add #ifdef
_WIN64 ... #else ... #endif

Timo

Alex Ionescu wrote:
> 1) Ask yourself why the compiler is emitting a warning when you use -1
> 2) Ask yourself how you are "fixing" this -- forcibly casting the type
> to silence the compiler. In other words, you are doing this:
>
> int foo(int* ptrToNumber);
> ...
> {
>     int number = 5;
>     foo((int*)number); // Hmm, compiler warns I need an int*... let me
> typecast, it seems to fix the warning.
> }
> 3) Ask yourself what ULONG means
> 4) And then ask yourself what -1 means
>
> If you still don't get it, go read a book on C.
>
> Best regards,
> Alex Ionescu
>
>
>
>   




More information about the Ros-dev mailing list