Hirrolot / datatype99

Algebraic data types for C99
MIT License
1.36k stars 23 forks source link

C++ compilation doesn't work #14

Closed Hirrolot closed 2 years ago

Hirrolot commented 2 years ago

Trying to compile examples/binary_tree.c on C++:

$ g++ examples/binary_tree.c -I. -Iexamples/build/_deps/metalang99-src/include -ftrack-macro-expansion=0
examples/binary_tree.c: In function ‘int sum(const BinaryTree*)’:
examples/binary_tree.c:17:9: error: invalid conversion from ‘void*’ to ‘Leaf_0*’ {aka ‘int*’} [-fpermissive]
   17 |         of(Leaf, x) return *x;
      |         ^~
      |         |
      |         void*
examples/binary_tree.c:17:9: error: invalid conversion from ‘void*’ to ‘Leaf_0*’ {aka ‘int*’} [-fpermissive]
   17 |         of(Leaf, x) return *x;
      |         ^~
      |         |
      |         void*
examples/binary_tree.c:18:9: error: invalid conversion from ‘void*’ to ‘BinaryTree**’ [-fpermissive]
   18 |         of(Node, lhs, x, rhs) return sum(*lhs) + *x + sum(*rhs);
      |         ^~
      |         |
      |         void*
examples/binary_tree.c:18:9: error: invalid conversion from ‘void*’ to ‘BinaryTree**’ [-fpermissive]
   18 |         of(Node, lhs, x, rhs) return sum(*lhs) + *x + sum(*rhs);
      |         ^~
      |         |
      |         void*
examples/binary_tree.c:18:9: error: invalid conversion from ‘void*’ to ‘Node_1*’ {aka ‘int*’} [-fpermissive]
   18 |         of(Node, lhs, x, rhs) return sum(*lhs) + *x + sum(*rhs);
      |         ^~
      |         |
      |         void*
examples/binary_tree.c:18:9: error: invalid conversion from ‘void*’ to ‘Node_1*’ {aka ‘int*’} [-fpermissive]
   18 |         of(Node, lhs, x, rhs) return sum(*lhs) + *x + sum(*rhs);
      |         ^~
      |         |
      |         void*
examples/binary_tree.c:18:9: error: invalid conversion from ‘void*’ to ‘BinaryTree**’ [-fpermissive]
   18 |         of(Node, lhs, x, rhs) return sum(*lhs) + *x + sum(*rhs);
      |         ^~
      |         |
      |         void*
examples/binary_tree.c:18:9: error: invalid conversion from ‘void*’ to ‘BinaryTree**’ [-fpermissive]
   18 |         of(Node, lhs, x, rhs) return sum(*lhs) + *x + sum(*rhs);
      |         ^~
      |         |
      |         void*

This is caused by https://github.com/Hirrolot/metalang99/issues/25 and was fixed in Metalang99 v1.13.2.