Well, C _can_ understand it. But that does not mean you should _want_ it to :)
    
    
    {.emit: """
    
    typedef long long int nim_int;
    
    struct nim_seq_hdr {
      nim_int len;
      nim_int reserved;
    };
    
    struct nim_string {
      struct nim_seq_hdr seq;
      char *data[0];
    };
    
    struct nim_string_seq {
      struct nim_seq_hdr seq;
      struct nim_string *data[0];
    };
    
    
    void foo(void *ptr)
    {
      struct nim_string_seq *n = *(struct nim_string_seq **)ptr;
      nim_int i;
      for(i=0; i<n->seq.len; i++) {
        struct nim_string *s = *(struct nim_string **)(&n->data[i]);
        printf("%d -> %d: %s\n", i, s->seq.len, s->data);
      }
    }
    
    
    """}
    
    proc foo(a1: pointer) {.cdecl, importc.}
    var a = @["one", "two", "three"]
    foo(addr a)
    
    
    Run

Reply via email to