#line 180 "/home/travis/build/felix-lang/felix/src/packages/libstruct.fdoc"
  
  This class provides access to raw C/C++ encodings.
  Incorrect typing is likely to pass by Felix and
  be trapped by the C/C++ compiler. Incorrect management
  of storage can lead to corruption. The use of the
  C_hack class is necessary for interfacing.
  class C_hack
  {
    C void type. Incomplete, can't be instantiated.
    incomplete type void_t = "void";
  
    Standard variable argument list pointer type.
    type va_list = "va_list";
  
    GCC specific valist thingo: it will
    be optimised away if not used (eg on MSVC).
    type __builtin_va_list = '__builtin_va_list';
  
    Throw away result of a function call:
    only useful for C functions that are mainly
    called for side effects.
    proc ignore[t]:t = "(void)$t;";
  
    C style cast.
    fun cast[dst,src]: src->dst = '(?1)($1:assign)' is cast;
  
    C++ static cast.
    fun static_cast[dst,src]: src->dst = 'static_cast<?1>($1)' is postfix;
  
    C++ dynamic cast.
    fun dynamic_cast[dst,src]: src->dst = 'dynamic_cast<?1>($1)' is postfix;
  
    C++ const cast.
    fun const_cast[dst,src]: src->dst = 'const_cast<?1>($1)' is postfix;
  
    C++ reinterpret cast.
    fun reinterpret_cast[dst,src]: src->dst = 'reinterpret_cast<?1>($1)' is postfix;
  
    Felix reinterpret cast.
    More powerful than C++ reinterpret cast.
    Allows casting an rvalue to an lvalue.
    fun reinterpret[dst,src]: src->dst = 'reinterpret<?1>($1)' is postfix;
  
    const sizeof[t]:size = 'sizeof(?1)';
  
    Special NULL check for Felix pointers.
    Should never succeed.
    fun isNULL[t]: &t -> bool = "(0==$1)";
  
    Special NULL check for carray.
    Should never succeed.
    fun isNULL[t]: +t -> bool = "(0==$1)";
  
    Polymorphic null pointer constant
    Values of this type should not exist.
    This value is provided for checking.
    const null[t]:&t = "(?1*)NULL";
  
    C++ default value for a type T.
    Workaround for g++ 3.2.2 parsing bug,
    it can parse T() as a default ctor call,
    but screws up on (T())
    fun dflt[t]:1->t = "dflt<?1>()" requires header
      "template<class T> T dflt() { return T(); }";
  
    body checked_malloc = """
      void *checked_malloc(size_t n) {
        void *p = ::std::malloc(n);
        if(p) return p;
        else throw "out of memory";
      }
    """;
  
    Raw unchecked malloc.
    Used typed malloc in carray if possible.
    gen raw_malloc: !ints -> address = '::std::malloc($1)' requires Cxx_headers::cstdlib;
  
    Malloc with out of memory check.
    Throws c"out of memory" if out of memory.
    gen malloc: !ints -> address = 'checked_malloc($1)' requires Cxx_headers::cstdlib, checked_malloc;
  
    Raw unchecked free.
    proc free: address = '::std::free($1);' requires Cxx_headers::cstdlib;
  
    Invoke C++ destructor
    proc destroy[T] : &T = "::destroy($1);/*C_hack*/"; // from flx_compiler_support_bodies
  }