avro-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Max Lysenko (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (AVRO-1958) The generated C++ code doesn't compile if there are several enums with identical item names.
Date Fri, 11 Nov 2016 09:38:58 GMT

    [ https://issues.apache.org/jira/browse/AVRO-1958?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15656631#comment-15656631
] 

Max Lysenko commented on AVRO-1958:
-----------------------------------

The attached Avro schema contains 2 enums (enumA and enumB) with an item named "VALUE_A".
Generate a cpp file for this schema:
{{avrogencpp -i DataSchema.avsc -o DataSchema.cpp}}
The generated source file will contain these definitions:
{noformat}
enum EnumA {
    VALUE_A,
    VALUE_B,
    VALUE_C,
};

enum EnumB {
    VALUE_A,
    VALUE_D,
    VALUE_E,
};
{noformat}
Obviously, that code won't compile. It is possible to fix it manually:
# Add a prefix to enum items (ENUMA_VALUE_A and ENUMB_ITEM_B) like the C code generator does.
# Provide each enum with its own namespace (e.g. enuma::EnumA). Ugly but works.
# Use a strongly typed enums from C++11.

It'd be great to have an option for {{avrogencpp}} to use one of above methods.

> The generated C++ code doesn't compile if there are several enums with identical item
names.
> --------------------------------------------------------------------------------------------
>
>                 Key: AVRO-1958
>                 URL: https://issues.apache.org/jira/browse/AVRO-1958
>             Project: Avro
>          Issue Type: Bug
>          Components: c++
>            Reporter: Max Lysenko
>         Attachments: DataSchema.avsc
>
>




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message