Re: Get gchar* from Glib::ustring



On 06/03/2009 02:08 PM, Fabrício Godoy wrote:
Thank you.

Can you say why the following code compile but don't work?


template<class T1, class T2, class T3>
Glib::ustring build_filename(const T1&  str1, const T2&  str2, const T3&  str3)
{
     Glib::ustring ustr1 = Glib::ustring::compose("%1", str1);
     Glib::ustring ustr2 = Glib::ustring::compose("%1", str2);
     Glib::ustring ustr3 = Glib::ustring::compose("%1", str3);

     gchar* path;

     path = g_build_filename(ustr1.c_str(), ustr2.c_str(), ustr3.c_str());


Because, as written in the Fine Manual, you must end the argument list with NULL.

There is also Glib::build_filename()

Since your description of "doesn't work" is missing I assume you are either getting a crash or garbage, depending on the phase of the moon and the age of the captain.

Hub


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