Missing definition(s) or macro(s) in generated C file

31 views
Skip to first unread message

Yannick Duchêne

unread,
Aug 9, 2014, 3:18:28 PM8/9/14
to ats-lan...@googlegroups.com
Hi all,

Trying to compile this short sample:

fun fact {n: nat} .<n>. (x: int n): int =
 
if x > 0
 
then x * fact (x - 1)
 
else 1


I get these errors (shortened version of the full output, for readability):

[…] In function fact_0’:
[…] PMVtmpltcstmat undeclared (first use in this function)
[…] gt_g1int_int undeclared (first use in this function)
[…] expected expression before atstype_int
[…] expected expression before ‘)’ token
[…] g1int_sub undeclared (first use in this function)
[…] expected expression before atstype_int
[…] expected expression before ‘)’ token
[…] g0int_mul undeclared (first use in this function)
[…] expected expression before atstype_int
[…] expected expression before ‘)’ token


There are errors looking like syntax errors to the C compiler (which is GCC), which in turn makes me suppose it may be due to missing macro(s) (I don't like C macros, and this kind of errors is one of the reason why).

May be I need to add a `-Dxxx` option to the command line when invoking `patscc`, but which one? Or is this another kind of issue?


Brandon Barker

unread,
Aug 9, 2014, 3:47:12 PM8/9/14
to ats-lang-users
I think you may need to #include "share/atspre_staload.hats"

Brandon Barker
brandon...@gmail.com
> --
> You received this message because you are subscribed to the Google Groups
> "ats-lang-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ats-lang-user...@googlegroups.com.
> To post to this group, send email to ats-lan...@googlegroups.com.
> Visit this group at http://groups.google.com/group/ats-lang-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ats-lang-users/70a505ec-6d89-4cca-96ca-82e2b1252fbc%40googlegroups.com.

Brandon Barker

unread,
Aug 9, 2014, 3:48:04 PM8/9/14
to ats-lang-users
When going for a compile (as opposed to the typecheck only) it may be
helpful to post the entire file being compiled (and maybe you did -
just wanted to verify).
Brandon Barker
brandon...@gmail.com

Yannick Duchêne

unread,
Aug 9, 2014, 4:25:37 PM8/9/14
to ats-lan...@googlegroups.com


Le samedi 9 août 2014 21:47:12 UTC+2, Brandon Barker a écrit :
I think you may need to  #include "share/atspre_staload.hats"
 
Indeed. I though all basic things were part of prelude.

About the prelude, the *.hats file mentions it, as starts with this comment:

(*
** This is mostly for staloading
** template code in ATSLIB/prelude
*)

Seems prelude needs it, so why isn't it automatically included?

I will start everything with this include, unless there are known case where it should not be included.

Brandon Barker

unread,
Aug 9, 2014, 4:42:12 PM8/9/14
to ats-lang-users
I think you are right that prelude is staloaded (don't quote me on
this for sure), but there are two kinds of staload:
https://github.com/githwxi/ATS-Postiats/wiki/staload

And I think it is only the first kind that patscc or patsopt does by default.
Brandon Barker
brandon...@gmail.com
> --
> You received this message because you are subscribed to the Google Groups
> "ats-lang-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ats-lang-user...@googlegroups.com.
> To post to this group, send email to ats-lan...@googlegroups.com.
> Visit this group at http://groups.google.com/group/ats-lang-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ats-lang-users/c163584c-b655-4ec5-b0a7-f474e3228f9c%40googlegroups.com.

gmhwxi

unread,
Aug 9, 2014, 5:00:41 PM8/9/14
to ats-lan...@googlegroups.com

>>Seems prelude needs it, so why isn't it automatically included?

Because it is not needed for everyone. Say you want to do kernel programming.

ATS is a very versatile language. The more you use it, the more you will find it out :)

Brandon Barker

unread,
Aug 9, 2014, 5:57:03 PM8/9/14
to ats-lang-users
This also seems FAQ-worthy:
https://github.com/githwxi/ATS-Postiats/wiki/Frequently-asked-questions
Brandon Barker
brandon...@gmail.com
> --
> You received this message because you are subscribed to the Google Groups
> "ats-lang-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ats-lang-user...@googlegroups.com.
> To post to this group, send email to ats-lan...@googlegroups.com.
> Visit this group at http://groups.google.com/group/ats-lang-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ats-lang-users/c631b140-71c2-41da-b129-9836eb5f8de2%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages