You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Marcel Pfütze (Jira)" <ji...@apache.org> on 2021/08/19 12:37:00 UTC

[jira] [Comment Edited] (AVRO-2598) C++ standard of library implies C++ standard of projects using Avro

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

Marcel Pfütze edited comment on AVRO-2598 at 8/19/21, 12:36 PM:
----------------------------------------------------------------

I would still prefer to change the implementation to move it completely to the implementation (a.k.a the cpp files). That should be quickly done and solves the issue.


was (Author: marcelpfuetze):
I would still prefer to change the implementation to either move it completely to the implementation (a.k.a the cpp files). That should be quickly done and solves the issue.

> C++ standard of library implies C++ standard of projects using Avro
> -------------------------------------------------------------------
>
>                 Key: AVRO-2598
>                 URL: https://issues.apache.org/jira/browse/AVRO-2598
>             Project: Apache Avro
>          Issue Type: Bug
>          Components: c++
>    Affects Versions: 1.9.0, 1.9.1
>            Reporter: Marcel Pfütze
>            Priority: Major
>
> SInce Avro 1.9.0 there is an if macro in a lot of headers that uses the current C++ standard.
>  If you build the library from source and use it in another project with a different C++ standard this can lead to segfaults.
> Example of macro:
> {code:c++}
> template<typename T> T& GenericDatum::value() {
>     return (type_ == AVRO_UNION) ?
> #if __cplusplus >= 201703L
>         std::any_cast<GenericUnion>(&value_)->datum().value<T>() :
>         *std::any_cast<T>(&value_);
> #else
>         boost::any_cast<GenericUnion>(&value_)->datum().value<T>() :
>         *boost::any_cast<T>(&value_);
> #endif
> {code}
> In our case we build the library from source (which uses the c+11 by default) and used it in a project using C+17. There's very little indication to the user why the crash happens.
> My proposals:
>  * Move implementation from header to source file so that the used standard is decided at build time.
>  * Use the [CMAKE_CXX_STANDARD |https://cmake.org/cmake/help/v3.1/variable/CMAKE_CXX_STANDARD.html] functionality provided by cmake to set the standard. In this way the standard can also easily set when building the code without actually manipulating the CMakeLists.txt file. Of course the --std=c++11 [here|https://github.com/apache/avro/blob/89218262cde62e98fcb3778b86cd3f03056c54f3/lang/c%2B%2B/CMakeLists.txt#L55] can be removed.



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