Home Help Center

The default value of struct member should being created in .h file

linkmanlinkman Member liao changbinOrganization: huhan universityProject: scada
when define struct as this:

struct {
int x = 1;
}anystruct;

the init code being created in .cpp file, when define in dll, the define can not being exported. The default value of struct member should being created in .h file.

Ice version (Ice 3.4.1)
Compiler version (Visual Studio 2008)
Operating system (Windows xp)

Comments

  • linkmanlinkman Member liao changbinOrganization: huhan universityProject: scada
    I haven changed myself

    begin from slice2cpp/gen.cpp line 1055

    H << sp << nl << "struct " << name;
    H << sb;
    if(p->hasDefaultValues())
    {
    H << nl << name << "() :";

    H.inc();
    writeDataMemberInitializers(H, dataMembers, _useWstring);
    H.dec();
    H << sb;
    H << eb;
    }
  • kpflemingkpfleming Member Kevin P. FlemingOrganization: Digium, Inc.Project: Asterisk SCF
    Indeed, writing the constructors for the structure in the header file would be beneficial, as it would also allow the compiler to inline them. The change you've suggested would probably be the right way to do it.
Sign In or Register to comment.