avro-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alexander Moriarty (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (AVRO-1936) avrogencpp, includes should have more gaurds or generate more headers
Date Fri, 21 Oct 2016 15:28:58 GMT

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

Alexander Moriarty commented on AVRO-1936:
------------------------------------------

sorry, I started talking about avdl files. but these are then turned into avsc files with
the java-tool and then given to the generator. 

> avrogencpp, includes should have more gaurds or generate more headers
> ---------------------------------------------------------------------
>
>                 Key: AVRO-1936
>                 URL: https://issues.apache.org/jira/browse/AVRO-1936
>             Project: Avro
>          Issue Type: Bug
>    Affects Versions: 1.8.1
>            Reporter: Alexander Moriarty
>
> Inside of an avdl file, one can include other avdl files. But the generated only one
header file is generated and it does not include guard the enums/structs which were defined
in the other avdl files.
> I have some basic records which I've defined in there own avdl files, and include them
inside of more complicated structures.
> All is well, until I try to include multiple of the avro generated header files.
> Inside of your AvrogencppTests you have gotten around this by giving each generated type
there own name space.
> As a test, I quickly modified the existing avrogencpp.cc to include an optional name
to CodeGen::guard.
> {code:none}
> std::string guard(const string& name="");
> [...]
> string CodeGen::guard(const string& name)
> {
>     string h = name.empty() ? headerFile_ : name;
>     makeCanonical(h, true);
>     return h + "_" + lexical_cast<string>(random_()) + "__H_";
> }
> {code}
> And then adding guards around each Enum, Record, Union, Traits, etc.
> Which works well enough. However... the guards do not include the namespace names, so
this change breaks your unit tests.
> As long as two higher level classes in the same namespace do not include the same subclasses
the generated header files can both be used, but if you have a basic data type like an Point(x,y)
which is used throughout the higher level classes then they will both redefine Point(x,y)
> On the Java side, everything is okay. Point(x,y) and all of the classes which include
Point are in their own files inside of a package.
> Is there any common way around this problem?



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

Mime
View raw message