VirtualBox

Changeset 103312 in vbox for trunk/doc


Ignore:
Timestamp:
Feb 12, 2024 1:07:59 PM (11 months ago)
Author:
vboxsync
Message:

docs/VBox-CodingGuidelines: Added warning about type promotion issues when using bitfield values in calculations.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/doc/VBox-CodingGuidelines.cpp

    r101582 r103312  
    181181 *   <li> Avoid throwing exceptions, always prefer returning statuses.
    182182 *        Crappy exception handling is rewared by a glass of water in the face.
     183 *
     184 *   <li> Always cast bitfields members to the desired type before using them in
     185 *        calculations as Visual C++ and g++/clang++ may use different types.
     186 *
     187 *        It seems like Visual C++ will use the basetype of the field, while the
     188 *        other two will narrow the type down to the number of bits specified
     189 *        and then subject it to standard type promotion which typically ends up
     190 *        with signed int.
    183191 *
    184192 * </ul>
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette