Interacting with C structs

Hi all,

I see in the tutorial that a C struct can be typedef’d with $extype, but
I can’t seem to create a value of the type with record syntax. How am I
meant to use extype?

~Shea

A version without $UN.cast:

typedef Cint2 =
$extype_struct"struct{int x;int y;}" of { x= int, y= int }

implement
main0 () =
{
//
var xy: Cint2;
val () = xy.x := 1
val () = xy.y := 2
//
val () = println! ("xy.x = ", xy.x)
val () = println! ("xy.y = ", xy.y)
//
} (* end of [main0] *)On Saturday, September 6, 2014 7:05:00 PM UTC-4, Brandon Barker wrote:

This seems to compile:

staload UN = “prelude/SATS/unsafe.sats”

typedef Cint2 = $extype"struct{ int x; int y; }"

implement
main0 () =
{
val y = @(7, 3)
val x: Cint2 = $UN.cast{Cint2}{@(int,int)}(y)
}

Brandon Barker
brand...@gmail.com <javascript:>

On Sat, Sep 6, 2014 at 6:36 PM, Shea Levy <sh...@shealevy.com <javascript:>> wrote:

Hi all,

I see in the tutorial that a C struct can be typedef’d with $extype, but
I can’t seem to create a value of the type with record syntax. How am I
meant to use extype?

~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...@googlegroups.com <javascript:>.
To post to this group, send email to ats-l...@googlegroups.com
<javascript:>.
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/20140906223644.GA6613%40nixos.hsd1.nh.comcast.net
.

This seems to compile:

staload UN = “prelude/SATS/unsafe.sats”

typedef Cint2 = $extype"struct{ int x; int y; }"

implement
main0 () =
{
val y = @(7, 3)
val x: Cint2 = $UN.cast{Cint2}{@(int,int)}(y)
}

Brandon Barker
brandon…@gmail.comOn Sat, Sep 6, 2014 at 6:36 PM, Shea Levy sh...@shealevy.com wrote:

Hi all,

I see in the tutorial that a C struct can be typedef’d with $extype, but
I can’t seem to create a value of the type with record syntax. How am I
meant to use extype?

~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/20140906223644.GA6613%40nixos.hsd1.nh.comcast.net
.