# Patscc generating invalid C code?

**URL:** <https://discourse.ats-lang.org/t/patscc-generating-invalid-c-code/520>\
**Category:** Google Group\
**Created:** [September 24, 2013, 12:23pm UTC](https://discourse.ats-lang.org/t/patscc-generating-invalid-c-code/520 "2013-09-24T12:23:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gmpos](https://avatars.discourse-cdn.com/v4/letter/g/a6a055/32.png) [@gmpos](https://discourse.ats-lang.org/u/gmpos)\
**Post date:** [September 24, 2013, 12:23pm UTC](https://discourse.ats-lang.org/t/patscc-generating-invalid-c-code/520/1 "2013-09-24T12:23:39Z")

</div>

I just tried to compile the following program:

implement main() = 1 + 1

And got this output from the compiler: [http://pastie.org/8350603](http://pastie.org/8350603)

The generated C source file is here: [http://pastie.org/8350616](http://pastie.org/8350616)

One of the lines it complains about (line 124) drew my attention:

ATSINSmove(tmpret0, PMVtmpltcstmat0(  
ATSPMVi0nt(1), ATSPMVi0nt(1))) ;

The angle brackets around S2Eextkind(…) caught my eye; that isn’t valid  
C. It looks like a C++ template. What’s going on?

-Ian

---

<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:** [September 24, 2013, 1:14pm UTC](https://discourse.ats-lang.org/t/patscc-generating-invalid-c-code/520/2 "2013-09-24T13:14:42Z")

</div>

ATSINSmove(tmpret0, PMVtmpltcstmat0(  
ATSPMVi0nt(1), ATSPMVi0nt(1))) ;

For now, this is actually a form of error message; it states that the  
template g1int\_add cannot be properly instantiated.  
More informative error messages are planned later.On Tuesday, September 24, 2013 8:23:39 AM UTC-4, Admin Postiats wrote:

> ---------- Forwarded message ----------  
> From: \<[i....@zenhack.net](mailto:i....@zenhack.net) \<javascript:\>\>  
> Date: Mon, Sep 23, 2013 at 11:38 PM  
> Subject: patscc generating invalid C code?  
> To: [ats-l...@googlegroups.com](mailto:ats-l...@googlegroups.com) \<javascript:\>
> 
> I just tried to compile the following program:
> 
> implement main() = 1 + 1
> 
> And got this output from the compiler: [http://pastie.org/8350603](http://pastie.org/8350603)
> 
> The generated C source file is here: [http://pastie.org/8350616](http://pastie.org/8350616)
> 
> One of the lines it complains about (line 124) drew my attention:
> 
> ATSINSmove(tmpret0, PMVtmpltcstmat0(  
> ATSPMVi0nt(1), ATSPMVi0nt(1))) ;
> 
> The angle brackets around S2Eextkind(…) caught my eye; that isn’t valid  
> C. It looks like a C++ template. What’s going on?
> 
> -Ian

---

<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:** [September 24, 2013, 12:31pm UTC](https://discourse.ats-lang.org/t/patscc-generating-invalid-c-code/520/3 "2013-09-24T12:31:06Z")

</div>

You need to put the following line at the beginning of your code:

#include “atspre\_staload.hats”

which lets the compiler to have access to various template implementations.On Tuesday, September 24, 2013 8:23:39 AM UTC-4, Admin Postiats wrote:

> ---------- Forwarded message ----------  
> From: \<[i....@zenhack.net](mailto:i....@zenhack.net) \<javascript:\>\>  
> Date: Mon, Sep 23, 2013 at 11:38 PM  
> Subject: patscc generating invalid C code?  
> To: [ats-l...@googlegroups.com](mailto:ats-l...@googlegroups.com) \<javascript:\>
> 
> I just tried to compile the following program:
> 
> implement main() = 1 + 1
> 
> And got this output from the compiler: [http://pastie.org/8350603](http://pastie.org/8350603)
> 
> The generated C source file is here: [http://pastie.org/8350616](http://pastie.org/8350616)
> 
> One of the lines it complains about (line 124) drew my attention:
> 
> ATSINSmove(tmpret0, PMVtmpltcstmat0(  
> ATSPMVi0nt(1), ATSPMVi0nt(1))) ;
> 
> The angle brackets around S2Eextkind(…) caught my eye; that isn’t valid  
> C. It looks like a C++ template. What’s going on?
> 
> -Ian
