# Compiling ATS to C++-compliant C code

**URL:** <https://discourse.ats-lang.org/t/compiling-ats-to-c-compliant-c-code/702>\
**Category:** Google Group\
**Created:** [December 13, 2014, 8:20am UTC](https://discourse.ats-lang.org/t/compiling-ats-to-c-compliant-c-code/702 "2014-12-13T08:20:26Z")\
**Posts on this page:** 1\
**Page:** 1

<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:** [December 13, 2014, 8:20am UTC](https://discourse.ats-lang.org/t/compiling-ats-to-c-compliant-c-code/702/1 "2014-12-13T08:20:26Z")

</div>

> It would be good to emit ATS as well. The ATS code would then be  
> translated  
> by the ATS compiler into C which would then be compiled as C++ into a  
> library  
> which is linked to the rest of the code. It’s _essential_ that ATS  
> compiler emits  
> C code which is also compliant C++ code (the primary requirement is to  
> note  
> that C++ REQUIRES an explicit cast converting from a void \* to another  
> pointer  
> type, C doesn’t: there are some other issues: C++ has strongly typed enums  
> for example, C doesn’t).

I have only done this on a very small scale.

Arduino programming uses C++. I compiled ATS source code into C code that  
can be compiled by ‘arduino’, which uses g++ (?). I used -fpermissive to  
bypass C++ typechecking.  
Not sure if -fpermissive will soon be deprecated. To use another C++  
compiler, we may need to insert  
a lot of static\_casts (and maybe reinterpret\_casts). This probably should  
be done by first implementing a  
tool (atscc2c++).
