[ros-dev] [ros-diffs] [cgutman] 44286: - Initialize SocketError to 0 to prevent a bogus error from GCC

Thomas Bluemel thomas at reactsoft.com
Wed Nov 25 23:54:29 CET 2009


What's the point of wrapping these initializations into macros?  Just 
initialize these variables to something meaningful.  If the compiler 
isn't sure (thus the warning), it will initialize the variable according 
to your code.  If it determines that that assignment is obsolete, the 
optimizer most likely removes it.  No ugly code neccessary.

Thomas
Alex Ionescu wrote:
> Microsoft deals with this often -- they even have a macro you should 
> probably use:
>
> //
> // The following macro is used to satisfy the compiler. Note that the
> // expressions/statements passed to this macro are not necessary for
> // correctness, but without them the compiler cannot compile with W4.
> //
>
> #define SATISFY_OVERZEALOUS_COMPILER(X) X
> You use it as such:
>
> SATISFY_OVERZEALOUS_COMPILER (SocketError = 0);
>   
> On 2009-11-25, at 2:28 PM, Dmitry Gorbachev wrote:
>
>> Notice that the warning is "may be used uninitialized" and not "is
>> used uninitialized", so it is correct, in a sense.
>>
>> _______________________________________________
>> Ros-dev mailing list
>> Ros-dev at reactos.org <mailto:Ros-dev at reactos.org>
>> http://www.reactos.org/mailman/listinfo/ros-dev
>
> Best regards,
> Alex Ionescu
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Ros-dev mailing list
> Ros-dev at reactos.org
> http://www.reactos.org/mailman/listinfo/ros-dev




More information about the Ros-dev mailing list