# Clueless re: gc

**URL:** <https://discourse.ats-lang.org/t/clueless-re-gc/85>\
**Category:** Google Group\
**Created:** [February 3, 2015, 9:47am UTC](https://discourse.ats-lang.org/t/clueless-re-gc/85 "2015-02-03T09:47:52Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Raoul\_Duke](https://avatars.discourse-cdn.com/v4/letter/r/bbe5ce/32.png) [@Raoul\_Duke](https://discourse.ats-lang.org/u/Raoul_Duke)\
**Post date:** [February 3, 2015, 9:47am UTC](https://discourse.ats-lang.org/t/clueless-re-gc/85/1 "2015-02-03T09:47:52Z")

</div>

uh, how do i enable GC? seems hard to find the answer.

[http://blog.gmane.org/gmane.comp.lang.ats.user](http://blog.gmane.org/gmane.comp.lang.ats.user)

That is confusing to me. It almost sounds like I have to re-build my  
ATS installation to get GC? I was assuming/hoping that it would be a  
flag passed to patscc that would let me do it  
per-file/project/something?

---

<div class="post-metadata">

**Author:** ![gmhwxi](https://avatars.discourse-cdn.com/v4/letter/g/67e7ee/32.png) [@gmhwxi](https://discourse.ats-lang.org/u/gmhwxi)\
**Post date:** [February 3, 2015, 8:37pm UTC](https://discourse.ats-lang.org/t/clueless-re-gc/85/2 "2015-02-03T20:37:47Z")

</div>

There are plenty examples like this. For instance, I once wrote a “worm”  
game that runs with GC support; the GUI for the game is based on GTK.  
I do not really feel that reading such examples would be very helpful. Just  
imagine that you will be using two sets of malloc/free in your code. And  
that  
is all.On Tuesday, February 3, 2015 at 1:40:49 PM UTC-5, Raoul Duke wrote:

> Do people have / I must go re-read in the docs any examples of doing:  
> ATS + GC calling into C libraries that themselves were not linked with  
> GC? I assume it is the same thing as if I were just doing that from  
> regular C/++? But then ATS has the advantage that if one can learn how  
> the linear etc. typing works then one can track that other non-GC  
> memory?

---

<div class="post-metadata">

**Author:** ![gmhwxi](https://avatars.discourse-cdn.com/v4/letter/g/67e7ee/32.png) [@gmhwxi](https://discourse.ats-lang.org/u/gmhwxi)\
**Post date:** [February 3, 2015, 8:26pm UTC](https://discourse.ats-lang.org/t/clueless-re-gc/85/3 "2015-02-03T20:26:07Z")

</div>

> Ok looking at the Makefile, I guess I really _do_ have to rebuild my  
> ATS installation. I can only have one option for GC and it is global,  
> at a time?!

No, you do not need to rebuild ATS. Whether your code runs with or without  
GC is extern to ATS. Think of GC as just another way to implement  
malloc/free.

> How does all this actually play out? If I’m writing ATS to work with  
> C++ libraries, can I use GC still in any easy way?
> 
> thanks :}

Sure. Your code uses malloc/free with GC support and C++ library code uses  
its own malloc/free.

---

<div class="post-metadata">

**Author:** ![Yannick\_Duchene](https://avatars.discourse-cdn.com/v4/letter/y/b77776/32.png) [@Yannick\_Duchene](https://discourse.ats-lang.org/u/Yannick_Duchene)\
**Post date:** [February 3, 2015, 10:08am UTC](https://discourse.ats-lang.org/t/clueless-re-gc/85/4 "2015-02-03T10:08:02Z")

</div>

> uh, how do i enable GC? seems hard to find the answer.
> 
> [http://blog.gmane.org/gmane.comp.lang.ats.user](http://blog.gmane.org/gmane.comp.lang.ats.user)
> 
> That is confusing to me. It almost sounds like I have to re-build my  
> ATS installation to get GC? I was assuming/hoping that it would be a  
> flag passed to patscc that would let me do it  
> per-file/project/something?

I believe you have to pass “-D\_ATS\_GCATS” to the command line (that’s  
“-D\_ATS\_GC” to disable it). I don’t think you have to build ATS with GC to  
use GC in applications translated to C with ATS.

---

<div class="post-metadata">

**Author:** ![Raoul\_Duke](https://avatars.discourse-cdn.com/v4/letter/r/bbe5ce/32.png) [@Raoul\_Duke](https://discourse.ats-lang.org/u/Raoul_Duke)\
**Post date:** [February 3, 2015, 8:46pm UTC](https://discourse.ats-lang.org/t/clueless-re-gc/85/5 "2015-02-03T20:46:00Z")

</div>

hi, Thanks for all the notes. I will go practice. 🙂

---

<div class="post-metadata">

**Author:** ![Raoul\_Duke](https://avatars.discourse-cdn.com/v4/letter/r/bbe5ce/32.png) [@Raoul\_Duke](https://discourse.ats-lang.org/u/Raoul_Duke)\
**Post date:** [February 3, 2015, 6:40pm UTC](https://discourse.ats-lang.org/t/clueless-re-gc/85/6 "2015-02-03T18:40:48Z")

</div>

Do people have / I must go re-read in the docs any examples of doing:  
ATS + GC calling into C libraries that themselves were not linked with  
GC? I assume it is the same thing as if I were just doing that from  
regular C/++? But then ATS has the advantage that if one can learn how  
the linear etc. typing works then one can track that other non-GC  
memory?

---

<div class="post-metadata">

**Author:** ![gmhwxi](https://avatars.discourse-cdn.com/v4/letter/g/67e7ee/32.png) [@gmhwxi](https://discourse.ats-lang.org/u/gmhwxi)\
**Post date:** [February 3, 2015, 8:20pm UTC](https://discourse.ats-lang.org/t/clueless-re-gc/85/7 "2015-02-03T20:20:22Z")

</div>

> > Enable GC

Say you have foo.dats and you want to run foo with GC support:

patscc -DATS\_MEMALLOC\_GCBDW -o foo foo.dats

You do not need to rebuild/reinstall ATS

You only need to rebuild ATS if you want to run patsopt with GC support.On Tuesday, February 3, 2015 at 4:47:53 AM UTC-5, Raoul Duke wrote:

> uh, how do i enable GC? seems hard to find the answer.
> 
> [http://blog.gmane.org/gmane.comp.lang.ats.user](http://blog.gmane.org/gmane.comp.lang.ats.user)
> 
> That is confusing to me. It almost sounds like I have to re-build my  
> ATS installation to get GC? I was assuming/hoping that it would be a  
> flag passed to patscc that would let me do it  
> per-file/project/something?

---

<div class="post-metadata">

**Author:** ![Yannick\_Duchene](https://avatars.discourse-cdn.com/v4/letter/y/b77776/32.png) [@Yannick\_Duchene](https://discourse.ats-lang.org/u/Yannick_Duchene)\
**Post date:** [February 3, 2015, 5:25pm UTC](https://discourse.ats-lang.org/t/clueless-re-gc/85/8 "2015-02-03T17:25:37Z")

</div>

Don’t thanks me for one error: to disable, it’s “-D\_ATS\_NGC” instead of  
“-D\_ATS\_GC” as I erroneously said.Le mardi 3 février 2015 17:10:55 UTC+1, Raoul Duke a écrit :

> thanks!

---

<div class="post-metadata">

**Author:** ![Raoul\_Duke](https://avatars.discourse-cdn.com/v4/letter/r/bbe5ce/32.png) [@Raoul\_Duke](https://discourse.ats-lang.org/u/Raoul_Duke)\
**Post date:** [February 3, 2015, 9:49am UTC](https://discourse.ats-lang.org/t/clueless-re-gc/85/9 "2015-02-03T09:49:58Z")

</div>

Ok looking at the Makefile, I guess I really _do_ have to rebuild my  
ATS installation. I can only have one option for GC and it is global,  
at a time?!

How does all this actually play out? If I’m writing ATS to work with  
C++ libraries, can I use GC still in any easy way?

thanks :}

---

<div class="post-metadata">

**Author:** ![Raoul\_Duke](https://avatars.discourse-cdn.com/v4/letter/r/bbe5ce/32.png) [@Raoul\_Duke](https://discourse.ats-lang.org/u/Raoul_Duke)\
**Post date:** [February 3, 2015, 4:10pm UTC](https://discourse.ats-lang.org/t/clueless-re-gc/85/10 "2015-02-03T16:10:54Z")

</div>

thanks!

---

<div class="post-metadata">

**Author:** ![gmhwxi](https://avatars.discourse-cdn.com/v4/letter/g/67e7ee/32.png) [@gmhwxi](https://discourse.ats-lang.org/u/gmhwxi)\
**Post date:** [February 3, 2015, 8:28pm UTC](https://discourse.ats-lang.org/t/clueless-re-gc/85/11 "2015-02-03T20:28:30Z")

</div>

-D\_ATS\_GCATS is only for ATS1; it is not available for code  
written in ATS2.

My understanding is that Raoul wants to run his own code (written in ATS2)  
with GC support.On Tuesday, February 3, 2015 at 5:08:02 AM UTC-5, Yannick Duchêne wrote:

> Le mardi 3 février 2015 10:47:53 UTC+1, Raoul Duke a écrit :
> 
> > uh, how do i enable GC? seems hard to find the answer.
> > 
> > [http://blog.gmane.org/gmane.comp.lang.ats.user](http://blog.gmane.org/gmane.comp.lang.ats.user)
> > 
> > That is confusing to me. It almost sounds like I have to re-build my  
> > ATS installation to get GC? I was assuming/hoping that it would be a  
> > flag passed to patscc that would let me do it  
> > per-file/project/something?
> 
> I believe you have to pass “-D\_ATS\_GCATS” to the command line (that’s  
> “-D\_ATS\_GC” to disable it). I don’t think you have to build ATS with GC to  
> use GC in applications translated to C with ATS.
