djinni icon indicating copy to clipboard operation
djinni copied to clipboard

Value is not set for a constant if it's defined as the value of another constant.

Open WoodyGuo opened this issue 6 years ago • 1 comments

In the following IDL file, there are 4 constants defined: days_7, days_14, days_30, and days_default. The days_default and the days_30 are having the same value.

`interface_xxx = interface +c {

const days_7: i8 = 7; const days_14: i8 = 14; const days_30: i8 = 30; const days_default: i8 = days_30;

}`

Compilation will fail after generating the code using the IDL file above, complaining with error "declaration of constexpr static data member 'DAYS_DEFAULT' requires an initializer".

Contents of the header and implementations files generated are listed below:

` // interface_xxx.h class InterfaceXxx { public: virtual ~InterfaceXxx() {}

static constexpr int8_t DAYS_7 = 7; static constexpr int8_t DAYS_14 = 14; static constexpr int8_t DAYS_30 = 30; static constexpr int8_t DAYS_DEFAULT; }`

` // interface_xxx.cc namespace ns {

int8_t const InterfaceXxx::DAYS_7; int8_t const InterfaceXxx::DAYS_14; int8_t const InterfaceXxx::DAYS_30; int8_t const InterfaceXxx::DAYS_DEFAULT;

}`

WoodyGuo avatar May 16 '18 09:05 WoodyGuo

Note from prior discussion elsewhere: Looks likely to have been introduced by #354

artwyman avatar May 17 '18 00:05 artwyman