• Johannes Sixt's avatar
    commit-slab.h: avoid duplicated global static variables · af920e36
    Johannes Sixt authored
    The gigantic define_commit_slab() macro repeats the definition of a
    static variable that occurs earlier in the macro text. The purpose of
    the repeated definition at the end of the macro is that it takes the
    semicolon that occurs where the macro is used.
    We cannot just remove the first definition of the variable because it
    is referenced elsewhere in the macro text, and defining the macro later
    would produce undefined identifier errors. We cannot have a "forward"
    declaration, either. (This works only with "extern" global variables.)
    The solution is to use a declaration of a struct that is already defined
    earlier. This language construct can serve the same purpose as the
    duplicated static variable definition, but without the confusion.
    Signed-off-by: default avatarJohannes Sixt <j6t@kdbg.org>
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
commit-slab.h 3.96 KB