[erlang-questions] Records referring to each other
Brujo Benavides @ Inaka
elbrujohalcon@REDACTED
Tue Jul 8 20:47:37 CEST 2014
This seems to work fine for me:
-module(corec).
-record(corec1, {other :: corec2()}).
-record(corec2, {other :: corec1()}).
-type corec1() :: #corec1{}.
-type corec2() :: #corec2{}.
Best regards,
On Jul 8, 2014, at 15:41, ANTHONY MOLINARO <anthonym@REDACTED> wrote:
> Hi,
>
> I came across it when trying to compile some generated test code in the thrift code base. The record definition looks like this,
>
> -ifndef(_recursive_types_included).
> -define(_recursive_types_included, yeah).
>
> %% struct coRec
>
> -record(coRec, {other :: #coRec2{}}).
>
> %% struct coRec2
>
> -record(coRec2, {other :: #coRec{}}).
>
> -endif.
>
> This returns the error
>
> test/recursive_types.hrl:16: record coRec2 undefined
>
> I’m wondering if there is any way to get this to work and include the types, or whether I should modify the generation to not include record types?
>
> Thanks,
>
> -Anthony
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
More information about the erlang-questions
mailing list