zserio icon indicating copy to clipboard operation
zserio copied to clipboard

Consider to filter out packed warning in templates

Open mikir opened this issue 3 years ago • 2 comments

If the structure does not contain any packable field, Zserio compiler fires warning if such structure is used in packed array.

However, if such packed array is used in template, user cannot fix this warning. Therefore, consider to implement some possibility of filtering out this warning in templates.

Example:

struct Packable
{
    uint32 id;
};

struct Unpackable
{
    string text;
};

struct PackedTemplate<T>
{
    packed T array[];
};

struct Warning
{
    PackedTemplate<Packable> noWarning;
    PackedTemplate<Unpackable> warning;
};

This example gives the following warning:

[WARNING] test.zs:19:5: In instantiation of 'PackedTemplate' required from here
[WARNING] test.zs:13:12: 'Unpackable' doesn't contain any packable field!

mikir avatar Feb 02 '22 08:02 mikir

Consider to introduce new command line argument to enable this warning for empty structures as well (see #364).

mikir avatar Feb 07 '22 14:02 mikir

It is just enough to create warning with new special specifier (tag) for this situation.

mikir avatar Oct 07 '22 10:10 mikir