Skip to content

warning C5246 - double curly braces #398

@BeErikk

Description

@BeErikk

Just FYI, using MSVCtools 14.42.34433, compiler 19.42.34438 (Visual Studio 2022) with -Wall, compiles gives:

argparse.hpp(1703): warning C5246: '_Elems': the initialization of a subobject should be wrapped in braces
argparse.hpp(1703): note: the template instantiation context (the oldest one first) is
argparse.hpp(1647): note: see reference to function template instantiation 'argparse::Argument &argparse::ArgumentParser::add_argument<const char*,const char*>(const char *,const char *)' being compiled

See for example discussion at stackoverflow double curly braces.

It's not an error but a simple solution is for example something like

#if defined(_MSC_VER)
#define MSDISABLE_WARNING_PUSH(x)	__pragma(warning(push));__pragma(warning(disable:x))
#define MSDISABLE_WARNING_POP		__pragma(warning(pop))
#else
#define MSDISABLE_WARNING_PUSH(x)
#define MSDISABLE_WARNING_POP
#endif

MSDISABLE_WARNING_PUSH(5246)
code ...
MSDISABLE_WARNING_POP

ugly though

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions