• P
    scripts/qapi-types.py: Add dummy member to empty structs · 83ecb22b
    Peter Maydell 提交于
    Make sure that all generated C structs have at least one field; this
    avoids potential issues with attempting to malloc space for
    zero-length structs in C (g_malloc(sizeof struct) would return NULL).
    It also avoids an incompatibility with C++ (where an empty struct is
    size 1); that isn't important to us now but might be in future.
    
    Generated empty structures look like this:
        struct Abort
        {
            char qapi_dummy_field_for_empty_struct;
        };
    
    This silences clang warnings like:
    ./qapi-types.h:3752:1: warning: empty struct has size 0 in C, size 1 in C++ [-Wextern-c-compat]
    struct Abort
    ^
    Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
    Reviewed-by: NEric Blake <eblake@redhat.com>
    Message-id: 1419359069-16611-1-git-send-email-peter.maydell@linaro.org
    83ecb22b
qapi-types.py 11.1 KB