You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Allen Reese (Jira)" <ji...@apache.org> on 2021/01/29 19:20:00 UTC

[jira] [Commented] (AVRO-3031) avrocppgen does not generate correct C++ code when the schema contains C++ reserved words.

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

Allen Reese commented on AVRO-3031:
-----------------------------------

I've opened a PR to fix this: [https://github.com/apache/avro/pull/1071]

 

> avrocppgen does not generate correct C++ code when the schema contains C++ reserved words.
> ------------------------------------------------------------------------------------------
>
>                 Key: AVRO-3031
>                 URL: https://issues.apache.org/jira/browse/AVRO-3031
>             Project: Apache Avro
>          Issue Type: Bug
>          Components: c++
>    Affects Versions: 1.10.1
>            Reporter: Allen Reese
>            Priority: Minor
>         Attachments: cannot-compile.cpp, cpp-reserved-wrods.avsc
>
>
> If avrogencpp is run against a schema that uses C++ reserved words for field names, it will generate C++ code that cannot be compiled.
> avrogencpp currently has a list of C++ reserved words, but it only checks this list when generating an enum, fixed, or record type:
> [https://github.com/apache/avro/blob/90d0a49d02416cac41962ac40d3662967febfcdb/lang/c%2B%2B/impl/avrogencpp.cc#L130-L142]
> The result is, if you have a schema such as cpp-reserved-words.avsc (attached)
> and run ```avrogencpp -i cpp-reserved-wrods.avsc -o cannot-compile.cpp```, avrogencpp will generate C++ code that cannot be compiled: cannot-compile.cpp (attached).
> The fix this involves calling decorate on all names, instead of in the few places it's already called.
>  
> I have a patch that fixes this and adds a unit test, and I will be opening a PR with the fix.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)