Skip to content

CPP generator: Move static definitions in *.cpp file. #377

@benderlog

Description

@benderlog

At the moment static definition are implemented in headers next to a generated class like this:

class ReportRequestUnacked
{
private:
...
static SBE_CONST_KIND std::uint16_t SbeBlockLength{(std::uint16_t)22};
    static const std::uint16_t sbeBlockLength(void)
    {
        return SbeBlockLength;
    }

    static SBE_CONST_KIND std::uint16_t SbeTemplateId{(std::uint16_t)17};
    static const std::uint16_t sbeTemplateId(void)
    {
        return SbeTemplateId;
    }

    static SBE_CONST_KIND std::uint16_t SbeSchemaId{(std::uint16_t)1};
    static const std::uint16_t sbeSchemaId(void)
    {
        return SbeSchemaId;
    }

    static SBE_CONST_KIND std::uint16_t SbeSchemaVersion{(std::uint16_t)1};
    static const std::uint16_t sbeSchemaVersion(void)
    {
        return SbeSchemaVersion;
    }

    static SBE_CONST_KIND char SbeSemanticType[] = "";
    static const char *sbeSemanticType(void)
    {
        return SbeSemanticType;
    }
...
};

SBE_CONST_KIND std::uint16_t ReportRequestUnacked::SbeBlockLength;
SBE_CONST_KIND std::uint16_t ReportRequestUnacked::SbeTemplateId;
SBE_CONST_KIND std::uint16_t ReportRequestUnacked::SbeSchemaId;
SBE_CONST_KIND std::uint16_t ReportRequestUnacked::SbeSchemaVersion;
SBE_CONST_KIND char ReportRequestUnacked::SbeSemanticType[];

So, it doesn't allow to re-use generated classes in separate source files of a project. Because we get a linker error like:
multiple definition of 'cboe_vni::ReportRequestUnacked::SbeSemanticType, etc

I suggest to move the static definitions in a *.cpp file or get rid of them at all.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions