Re: Strings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Philip Herron <redbrain@xxxxxxxxxxx> writes:

> Just around GENERIC question i've been grep'ing around the tree and
> havent found much on how to setup strings. say i wanted to simply do:
>
> const char * = "foobar"; in C how would i represent this so far i
> though yeah go through the usual:
>
> build_decl (VAR_DECL ....) etc with the nessecary TREE_STATIC etc. I
> saw some golang code and saw the code to generate the type for const
> char * i think:
>
> tree const_char_type = build_qualified_type(unsigned_char_type_node,
> 					      TYPE_QUAL_CONST);
>   tree ctype = build_pointer_type(const_char_type);
>   gpy_preserve_from_gc(ctype);
>
> Then i thought it would be simply DECL_INITIAL = build_string
> (length,"foobar"); but i get some segfalut after i pass the stuff to
> the middle end. So i dont think i done this quite right.

I think you want build_fold_addr_expr(build_string(length, "foobar")).

Ian


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux