Skip to content

atdcpp: recursive types render cpp code that fails to compile #414

@dlindsaye

Description

@dlindsaye

First of all .. thanks to everyone who contributes to these tools.

Unfortunately I have run into a problem with atdcpp when using recursive types. Given the following (recurisive.atd):

type expr = [
  | Int of int
  | Negate of expr
]

I can run atdcpp to produce recursive_atd.cpp and recursive_atd.hpp. Compiling with:

 g++ -c -I ~/Work/rapidjson/include -std=c++17 recusive_atd.cpp 

yields a ton of error messages including:

/usr/include/c++/8/type_traits:1222:12: error: invalid use of incomplete type ‘struct atd::Expr::Types::Negate’
     struct is_trivially_destructible
            ^~~~~~~~~~~~~~~~~~~~~~~~~
In file included from recusive_atd.cpp:12:
recusive_atd.hpp:46:16: note: forward declaration of ‘struct atd::Expr::Types::Negate’
         struct Negate
                ^~~~~~

which to me, as a newbie C++ developer, suggests trouble with the forward declarations.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions