Sorry if this has been asked/answered before but I've been out of the loop for a while..

I was just thinking about the recent discussion on renaming toStringz and I wondered why we need to explicitly call it at all. Why can't we have the compiler call it automatically whenever we pass a string, or char[] to an extern "C" function, where the parameter is defined as char*?

I believe some extern "C" functions are defined as taking ubyte* or byte* instead of char*, but in those cases I believe they are 'buffers' and have a supplied length as well, meaning there is no need for the trailing \0 in any case.

I am probably missing something obvious, but it seems like it might work.

Side note.. It bothers me a little that 'char' means utf-8 codepoint in D, and means unsigned byte in extern "C" definitions, but I can live with that.

--
Using Opera's revolutionary email client: http://www.opera.com/mail/

Reply via email to