VirtualBox

Changeset 84509 in vbox


Ignore:
Timestamp:
May 25, 2020 3:09:24 PM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
138238
Message:

iprt/cdefs.h,*: Introducing RT_FLEXIBLE_ARRAY_EXTENSION as a g++ hack that allows us to use RT_FLEXIBLE_ARRAY without the compiler going all pendantic on us. Only tested with 10.1.0. bugref:9746

Location:
trunk
Files:
30 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/VBoxGuestLibSharedFoldersInline.h

    r82968 r84509  
    970970    VMMDevHGCMCall          Call;
    971971    VBoxSFParmRead          Parms;
     972    RT_FLEXIBLE_ARRAY_EXTENSION
    972973    uint8_t                 abData[RT_FLEXIBLE_ARRAY];
    973974} VBOXSFREADEMBEDDEDREQ;
     
    11171118    VMMDevHGCMCall          Call;
    11181119    VBoxSFParmWrite         Parms;
     1120    RT_FLEXIBLE_ARRAY_EXTENSION
    11191121    uint8_t                 abData[RT_FLEXIBLE_ARRAY];
    11201122} VBOXSFWRITEEMBEDDEDREQ;
  • trunk/include/VBox/vmm/pdmpcidev.h

    r82968 r84509  
    244244    uint8_t                 abConfig[4096];
    245245    /** The MSI-X state data.  Optional. */
     246    RT_FLEXIBLE_ARRAY_EXTENSION
    246247    uint8_t                 abMsixState[RT_FLEXIBLE_ARRAY];
    247248} PDMPCIDEV;
  • trunk/include/iprt/cdefs.h

    r83813 r84509  
    25442544 * with a flexible size.
    25452545 *
     2546 * @note    RT_FLEXIBLE_ARRAY_EXTENSION must always preceed the type, unless
     2547 *          it's C-only code.
     2548 *
    25462549 * @note    Use RT_UOFFSETOF() to calculate the structure size.
    25472550 *
     
    25592562 */
    25602563#if RT_MSC_PREREQ(RT_MSC_VER_VS2005) /** @todo Probably much much earlier. */ \
    2561  || (defined(__cplusplus) && RT_GNUC_PREREQ(6, 1) && !RT_GNUC_PREREQ(7, 0)) /* gcc-7 warns again */\
     2564 || (defined(__cplusplus) && (   RT_GNUC_PREREQ(6, 1) \
     2565                              && (  !RT_GNUC_PREREQ(7, 0) /* gcc-7 warns again */ \
     2566                                  || RT_GNUC_PREREQ(10, 0) /* gcc-10 works with __extension__, the ones in between needs testing */ ))) \
    25622567 || defined(__WATCOMC__) /* openwatcom 1.9 supports it, we don't care about older atm. */ \
    25632568 || RT_CLANG_PREREQ_EX(3, 4, 0) /* Only tested clang v3.4, support is probably older. */
     
    25742579#else
    25752580# define RT_FLEXIBLE_ARRAY                      1
     2581#endif
     2582
     2583/** @def RT_FLEXIBLE_ARRAY_EXTENSION
     2584 * A trick to make GNU C++ quietly accept flexible arrays in C++ code when
     2585 * pedantic warnings are enabled.  Put this on the line before the flexible
     2586 * array. */
     2587#if (RT_GNUC_PREREQ(10, 0) && defined(__cplusplus)) || defined(DOXGYEN_RUNNING)
     2588# define RT_FLEXIBLE_ARRAY_EXTENSION            RT_GCC_EXTENSION
     2589#else
     2590# define RT_FLEXIBLE_ARRAY_EXTENSION
    25762591#endif
    25772592
  • trunk/include/iprt/crypto/applecodesign.h

    r82968 r84509  
    148148    uint32_t            cSlots;
    149149    /** Slots. */
     150    RT_FLEXIBLE_ARRAY_EXTENSION
    150151    RTCRAPLCSBLOBSLOT   aSlots[RT_FLEXIBLE_ARRAY];
    151152} RTCRAPLCSSUPERBLOB;
  • trunk/include/iprt/crypto/pem.h

    r84230 r84509  
    9090    size_t              cchName;
    9191    /** The field name. */
     92    RT_FLEXIBLE_ARRAY_EXTENSION
    9293    char                szName[RT_FLEXIBLE_ARRAY];
    9394} RTCRPEMFIELD;
  • trunk/include/iprt/formats/iso9660.h

    r82968 r84509  
    239239    uint16_t            idParentRec;
    240240    /** 0x08: Directory identifier (d-characters or d1-characters). */
     241    RT_FLEXIBLE_ARRAY_EXTENSION
    241242    char                achDirId[RT_FLEXIBLE_ARRAY];
    242243    /* There will be a zero padding byte following if the directory identifier length is odd. */
     
    291292    ISO9660U16          cbAppUse;
    292293    /** 0x0fa: Variable sized application use field. */
     294    RT_FLEXIBLE_ARRAY_EXTENSION
    293295    uint8_t             abAppUse[RT_FLEXIBLE_ARRAY];
    294296    /* This is followed by escape sequences with length given by cbEscapeSequnces. */
  • trunk/include/iprt/formats/mach-o.h

    r82968 r84509  
    632632    uint32_t            sdk;        /**< SDK version:        31..16=major, 15..8=minor, 7..0=patch */
    633633    uint32_t            ntools;     /**< Number of build_tool_version entries following in aTools. */
     634    RT_FLEXIBLE_ARRAY_EXTENSION
    634635    build_tool_version_t aTools[RT_FLEXIBLE_ARRAY];
    635636} build_version_command_t;
  • trunk/include/iprt/formats/ntfs.h

    r82968 r84509  
    381381    uint16_t            idAttrib;
    382382    /** 0x1a: Maybe where the attribute name starts. */
     383    RT_FLEXIBLE_ARRAY_EXTENSION
    383384    RTUTF16             wszName[RT_FLEXIBLE_ARRAY];
    384385} NTFSATLISTENTRY;
     
    499500    uint8_t             fFilenameType;
    500501    /** 0x42: The filename. */
     502    RT_FLEXIBLE_ARRAY_EXTENSION
    501503    RTUTF16             wszFilename[RT_FLEXIBLE_ARRAY];
    502504} NTFSATFILENAME;
  • trunk/include/iprt/formats/pecoff.h

    r84361 r84509  
    721721    RT_GCC_EXTENSION uint8_t    FrameOffset : 4;
    722722    /** Unwind opcodes. */
    723     IMAGE_UNWIND_CODE   aOpcodes[RT_FLEXIBLE_ARRAY];
     723    RT_FLEXIBLE_ARRAY_EXTENSION
     724    IMAGE_UNWIND_CODE           aOpcodes[RT_FLEXIBLE_ARRAY];
    724725} IMAGE_UNWIND_INFO;
    725726AssertCompileMemberOffset(IMAGE_UNWIND_INFO, aOpcodes, 4);
  • trunk/include/iprt/formats/udf.h

    r82968 r84509  
    792792    /** 0x1b8: Partition maps (length given by @a cbMapTable), data format is
    793793     * defined by UDFPARTMAPHDR, UDFPARTMAPTYPE1 and UDFPARTMAPTYPE2. */
     794    RT_FLEXIBLE_ARRAY_EXTENSION
    794795    uint8_t         abPartitionMaps[RT_FLEXIBLE_ARRAY];
    795796} UDFLOGICALVOLUMEDESC;
     
    925926    uint32_t        cAllocationDescriptors;
    926927    /** 0x18: Allocation descriptors (variable length). */
     928    RT_FLEXIBLE_ARRAY_EXTENSION
    927929    UDFEXTENTAD     aAllocationDescriptors[RT_FLEXIBLE_ARRAY];
    928930} UDFUNALLOCATEDSPACEDESC;
     
    975977     * the implementation to use.
    976978     */
     979    RT_FLEXIBLE_ARRAY_EXTENSION
    977980    uint32_t        aTables[RT_FLEXIBLE_ARRAY];
    978981} UDFLOGICALVOLINTEGRITYDESC;
     
    10751078     * After that is a d-string field with the name of the file, length
    10761079     * specified by @a cbName. */
     1080    RT_FLEXIBLE_ARRAY_EXTENSION
    10771081    uint8_t         abImplementationUse[RT_FLEXIBLE_ARRAY];
    10781082} UDFFILEIDDESC;
     
    13581362    /** 0xb0: Two variable sized fields.  First @a cbExtAttribs bytes of extended
    13591363     *  attributes, then @a cbAllocDescs bytes of allocation descriptors. */
     1364    RT_FLEXIBLE_ARRAY_EXTENSION
    13601365    uint8_t         abExtAttribs[RT_FLEXIBLE_ARRAY];
    13611366} UDFFILEENTRY;
     
    19711976    uint32_t        cbBitmap;
    19721977    /** 0x18: The bitmap. */
     1978    RT_FLEXIBLE_ARRAY_EXTENSION
    19731979    uint8_t         abBitmap[RT_FLEXIBLE_ARRAY];
    19741980} UDFSPACEBITMAPDESC;
     
    20002006    UDFENTITYID     idImplementation;
    20012007    /** 0x100: Implementation use data. */
     2008    RT_FLEXIBLE_ARRAY_EXTENSION
    20022009    uint8_t         abImplementationUse[RT_FLEXIBLE_ARRAY];
    20032010} UDFPARTITIONINTEGRITYDESC;
     
    20672074    /** 0xd8: Two variable sized fields.  First @a cbExtAttribs bytes of extended
    20682075     *  attributes, then @a cbAllocDescs bytes of allocation descriptors. */
     2076    RT_FLEXIBLE_ARRAY_EXTENSION
    20692077    uint8_t         abExtAttribs[RT_FLEXIBLE_ARRAY];
    20702078} UDFEXFILEENTRY;
  • trunk/include/iprt/nt/hyperv.h

    r82968 r84509  
    3636#else
    3737# define RT_FLEXIBLE_ARRAY
     38# define RT_FLEXIBLE_ARRAY_EXTENSION
    3839# define AssertCompile(expr)
    3940# define AssertCompileSize(type, size)
     
    498499    uint32_t            u32ExplicitPadding;
    499500    /* The repeating part: */
     501    RT_FLEXIBLE_ARRAY_EXTENSION
    500502    HV_SPA_PAGE_NUMBER  PageList[RT_FLEXIBLE_ARRAY];
    501503} HV_INPUT_MAP_GPA_PAGES;
     
    521523    uint32_t            u32ExplicitPadding;
    522524    /* The repeating part: */
     525    RT_FLEXIBLE_ARRAY_EXTENSION
    523526    HV_GPA_MAPPING      PageList[RT_FLEXIBLE_ARRAY];
    524527} HV_INPUT_MAP_SPARSE_GPA_PAGES;
     
    12341237    uint32_t            fFlags;
    12351238    /* The repeating part: */
     1239    RT_FLEXIBLE_ARRAY_EXTENSION
    12361240    HV_REGISTER_NAME    Names[RT_FLEXIBLE_ARRAY];
    12371241} HV_INPUT_GET_VP_REGISTERS;
     
    12681272    uint32_t            RsvdZ;
    12691273    /* The repeating part: */
     1274    RT_FLEXIBLE_ARRAY_EXTENSION
    12701275    HV_REGISTER_ASSOC   Elements[RT_FLEXIBLE_ARRAY];
    12711276} HV_INPUT_SET_VP_REGISTERS;
  • trunk/include/iprt/path.h

    r82968 r84509  
    741741     *       of the last component.  If RTPATH_PROP_DIR_SLASH is set, there may
    742742     *       be one or more trailing slashes that are unaccounted for! */
     743    RT_FLEXIBLE_ARRAY_EXTENSION
    743744    struct
    744745    {
     
    833834    const char *pszSuffix;
    834835    /** Array of component strings (variable size). */
     836    RT_FLEXIBLE_ARRAY_EXTENSION
    835837    char       *apszComps[RT_FLEXIBLE_ARRAY];
    836838} RTPATHSPLIT;
  • trunk/src/VBox/Additions/os2/VBoxSF/VBoxSFInternal.h

    r79112 r84509  
    8787    uint8_t             cchName;
    8888    /** The shared folder name.  If there is a tag it follows as a second string. */
     89    RT_FLEXIBLE_ARRAY_EXTENSION
    8990    char                szName[RT_FLEXIBLE_ARRAY];
    9091} VBOXSFFOLDER;
  • trunk/src/VBox/Devices/VirtIO/Virtio_1_0.cpp

    r84468 r84509  
    9696    uint16_t  fFlags;                                            /**< flags      avail ring guest-to-host flags */
    9797    uint16_t  uIdx;                                              /**< idx        Index of next free ring slot   */
     98    RT_FLEXIBLE_ARRAY_EXTENSION
    9899    uint16_t  auRing[RT_FLEXIBLE_ARRAY];                         /**< ring       Ring: avail drv to dev bufs    */
    99100    /* uint16_t  uUsedEventIdx;                                     - used_event (if VIRTQ_USED_F_EVENT_IDX)    */
     
    110111    uint16_t  fFlags;                                            /**< flags       used ring host-to-guest flags */
    111112    uint16_t  uIdx;                                              /**< idx         Index of next ring slot       */
     113    RT_FLEXIBLE_ARRAY_EXTENSION
    112114    VIRTQ_USED_ELEM_T aRing[RT_FLEXIBLE_ARRAY];                  /**< ring        Ring: used dev to drv bufs    */
    113115    /* uint16_t  uAvailEventIdx;                                    - avail_event if (VIRTQ_USED_F_EVENT_IDX)   */
  • trunk/src/VBox/Devices/testcase/tstDeviceInternal.h

    r83296 r84509  
    131131    size_t                          cbAlloc;
    132132    /** Start of the real allocation. */
     133    RT_FLEXIBLE_ARRAY_EXTENSION
    133134    uint8_t                         abAlloc[RT_FLEXIBLE_ARRAY];
    134135} TSTDEVMMHEAPALLOC;
  • trunk/src/VBox/HostServices/GuestControl/VBoxGuestControlSvc.cpp

    r83506 r84509  
    843843    uint32_t    cbKey;
    844844    /** The key bytes. */
     845    RT_FLEXIBLE_ARRAY_EXTENSION
    845846    uint8_t     abKey[RT_FLEXIBLE_ARRAY];
    846847} GstCtrlPreparedSession;
  • trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-internal.h

    r84142 r84509  
    5757    uint32_t            cParms;
    5858    /** HGCM parameters. */
     59    RT_FLEXIBLE_ARRAY_EXTENSION
    5960    VBOXHGCMSVCPARM     aParms[RT_FLEXIBLE_ARRAY];
    6061} SHCLCLIENTMSG;
  • trunk/src/VBox/Runtime/common/checksum/manifest2.cpp

    r82968 r84509  
    6565    bool                fVisited;
    6666    /** The normalized property name that StrCore::pszString points at. */
     67    RT_FLEXIBLE_ARRAY_EXTENSION
    6768    char                szName[RT_FLEXIBLE_ARRAY];
    6869} RTMANIFESTATTR;
  • trunk/src/VBox/Runtime/common/dbg/dbgmodmapsym.cpp

    r82968 r84509  
    6767    uint8_t     cchMaxSym;                      /**< 0x0e: Maximum symbol-name length. */
    6868    uint8_t     cchModule;                      /**< 0x0f: Length of the module name. */
     69    RT_FLEXIBLE_ARRAY_EXTENSION
    6970    char        achModule[RT_FLEXIBLE_ARRAY];   /**< 0x10: Module name, length given by cchModule. */
    7071} MAPSYMHDR;
     
    9293    uint16_t    u16Reserved2;                  /**< 0x12: Reserved / unknown.  Often seen holding 0xff00. */
    9394    uint8_t     cchSegName;                    /**< 0x14: Segment name length. */
     95    RT_FLEXIBLE_ARRAY_EXTENSION
    9496    char        achSegName[RT_FLEXIBLE_ARRAY]; /**< 0x15: Segment name, length given by cchSegName. */
    9597} MAPSYMSEGDEF;
     
    122124    uint16_t    cLines;                        /**< 0x08: Number of line numbers in the array. */
    123125    uint8_t     cchSrcFile;                    /**< 0x0a: Length of source filename. */
     126    RT_FLEXIBLE_ARRAY_EXTENSION
    124127    char        achSrcFile[RT_FLEXIBLE_ARRAY]; /**< 0x0b: Source filename, length given by cchSrcFile. */
    125128} MAPSYMLINEDEF;
  • trunk/src/VBox/Runtime/common/fs/RTFsCmdLs.cpp

    r82968 r84509  
    6464    size_t      cchName;
    6565    /** The entry name. */
     66    RT_FLEXIBLE_ARRAY_EXTENSION
    6667    char        szName[RT_FLEXIBLE_ARRAY];
    6768} RTCMDLSENTRY;
     
    9091
    9192    /** The collection name (path). */
     93    RT_FLEXIBLE_ARRAY_EXTENSION
    9294    char            szName[RT_FLEXIBLE_ARRAY];
    9395} RTCMDLSCOLLECTION;
  • trunk/src/VBox/Runtime/common/fs/fatvfs.cpp

    r82968 r84509  
    320320    const char             *pszName;
    321321    /** Cache entries. */
     322    RT_FLEXIBLE_ARRAY_EXTENSION
    322323    RTFSFATCLUSTERMAPENTRY  aEntries[RT_FLEXIBLE_ARRAY];
    323324} RTFSFATCLUSTERMAPCACHE;
  • trunk/src/VBox/Runtime/common/fs/isomaker.cpp

    r82968 r84509  
    258258    uint16_t                cchName;
    259259    /** The name. */
     260    RT_FLEXIBLE_ARRAY_EXTENSION
    260261    char                    szName[RT_FLEXIBLE_ARRAY];
    261262} RTFSISOMAKERNAME;
     
    448449    uint16_t                cchTarget;
    449450    /** The symbolic link target. */
     451    RT_FLEXIBLE_ARRAY_EXTENSION
    450452    char                    szTarget[RT_FLEXIBLE_ARRAY];
    451453} RTFSISOMAKERSYMLINK;
  • trunk/src/VBox/Runtime/common/ldr/ldrLX.cpp

    r82968 r84509  
    157157    uint32_t                cSegments;
    158158    /** Segment info. */
     159    RT_FLEXIBLE_ARRAY_EXTENSION
    159160    RTLDRSEG                aSegments[RT_FLEXIBLE_ARRAY];
    160161} KLDRMODLX, *PKLDRMODLX;
  • trunk/src/VBox/Runtime/common/vfs/vfsfss2dir.cpp

    r84192 r84509  
    6565    /** The name (relative to RTVFSFSSWRITE2DIR::szBaseDir). */
    6666#endif
     67    RT_FLEXIBLE_ARRAY_EXTENSION
    6768    char            szName[RT_FLEXIBLE_ARRAY];
    6869} RTVFSFSSWRITE2DIRENTRY;
     
    8788#else
    8889    /** Path to the directory that all operations are relative to. */
     90    RT_FLEXIBLE_ARRAY_EXTENSION
    8991    char            szBaseDir[RT_FLEXIBLE_ARRAY];
    9092#endif
  • trunk/src/VBox/Runtime/common/vfs/vfsstddir.cpp

    r82968 r84509  
    7575    PRTVFSSTDDIR    pDir;
    7676    /** The symbolic link name. */
     77    RT_FLEXIBLE_ARRAY_EXTENSION
    7778    char            szSymlink[RT_FLEXIBLE_ARRAY];
    7879} RTVFSSTDSYMLINK;
  • trunk/src/VBox/Runtime/generic/ftp-server.cpp

    r82842 r84509  
    105105    size_t      cchName;
    106106    /** The entry name. */
     107    RT_FLEXIBLE_ARRAY_EXTENSION
    107108    char        szName[RT_FLEXIBLE_ARRAY];
    108109} RTFTPDIRENTRY;
  • trunk/src/VBox/Runtime/generic/http-curl.cpp

    r83356 r84509  
    128128    uint32_t            offValue;
    129129    /** The full header field. */
    130     char                szData[RT_FLEXIBLE_ARRAY];
     130    RT_FLEXIBLE_ARRAY_EXTENSION
     131    RT_GCC_EXTENSION char szData[RT_FLEXIBLE_ARRAY];
    131132} RTHTTPHEADER;
    132133/** Pointer to a HTTP header. */
  • trunk/src/VBox/Runtime/tools/RTLdrCheckImports.cpp

    r82968 r84509  
    103103    uint32_t                cImports;
    104104    /** Import modules. */
     105    RT_FLEXIBLE_ARRAY_EXTENSION
    105106    RTCHECKIMPORTMODULE     aImports[RT_FLEXIBLE_ARRAY];
    106107} RTCHECKIMPORTSTATE;
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/VBoxBs3ObjConverter.cpp

    r83773 r84509  
    38073807    struct OMFDETAILSALLOC *pNext;
    38083808    /** The allocated bytes. */
     3809    RT_FLEXIBLE_ARRAY_EXTENSION
    38093810    uint8_t                 abData[RT_FLEXIBLE_ARRAY];
    38103811} OMFDETAILSALLOC;
  • trunk/src/VBox/ValidationKit/utils/fs/FsPerf.cpp

    r83986 r84509  
    268268    RTLISTNODE  Entry;
    269269    uint16_t    cchName;
     270    RT_FLEXIBLE_ARRAY_EXTENSION
    270271    char        szName[RT_FLEXIBLE_ARRAY];
    271272} FSPERFNAMEENTRY;
Note: See TracChangeset for help on using the changeset viewer.

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