Archived

This forum has been archived. Please start a new discussion on GitHub.

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

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

  • 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;
    }
  • 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.