[
https://issues.apache.org/jira/browse/AVRO-1958?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15656631#comment-15656631
]
Max Lysenko edited comment on AVRO-1958 at 11/11/16 10:07 AM:
--------------------------------------------------------------
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_VALUE_A).
# 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.
was (Author: maxl):
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_VALUE_A) 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)