Importing constants from C headers?

36 views
Skip to first unread message

Shea Levy

unread,
Aug 31, 2014, 10:49:43 PM8/31/14
to ats-lan...@googlegroups.com
Hi all,

Is there a general way to import preprocessor-defined constants from C
headers into the statics language? $extval can't be used there.

~Shea

Brandon Barker

unread,
Aug 31, 2014, 11:09:18 PM8/31/14
to ats-lang-users
I also wondered about this. I couldn't figure out how to do it, so I just defined it twice (see #define N in https://github.com/githwxi/ATS-Postiats-contrib/blob/master/contrib/libats-/bbarker/OpenMP/TEST/omp_for.dats). I agree this is not really satisfactory since it seems error prone.


Brandon Barker
brandon...@gmail.com



~Shea

--
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/20140901024939.GC2219%40nixos.hsd1.nh.comcast.net.

Hongwei Xi

unread,
Aug 31, 2014, 11:22:02 PM8/31/14
to ats-lan...@googlegroups.com
Not sure what you want exactly.

I did something like this a while ago:

https://sourceforge.net/p/ats-lang/code/HEAD/tree/trunk/contrib/glib/HATS/glibconfig_hats

Then I used 'gcc -E' to preprocess glibconfig_hats to generate a HATS file glibconfig.hats, which
can be included in ATS code directly.


On Sun, Aug 31, 2014 at 10:49 PM, Shea Levy <sh...@shealevy.com> wrote:

~Shea

Shea Levy

unread,
Aug 31, 2014, 11:27:27 PM8/31/14
to ats-lan...@googlegroups.com
Ah, that's a clever approach. I'll try something like that, thanks!
> To view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/CAPPSPLomq6heBJ10ftgXVGLY8sgTF8vzMdPET4KysfTmjtGSwg%40mail.gmail.com.

gmhwxi

unread,
Aug 31, 2014, 11:49:15 PM8/31/14
to ats-lan...@googlegroups.com
The opposite direction is easier.

Say you store the following line in a file mydefine.hats

#define N 100

Then just put the following lines at the beginning of your code:

%{^
#include "define.hats"
%}
#include "define.hats"

It shouldn't be too bad ...

Brandon Barker

unread,
Sep 1, 2014, 12:05:32 AM9/1/14
to ats-lang-users
That would do it; somehow it never crossed my mind to #include a .hats file.

Brandon Barker
brandon...@gmail.com


Reply all
Reply to author
Forward
0 new messages