June 04, 2004 Re: [BUG] Re: how to check char[ ] is empty | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | I think *all* interaction with any native C APIs should be done through thin layers that handle all issues of char[] <-> char*. std.recls.d has examples of these, although I'd be the first to acknowledge that they may not be perfect. "Walter" <newshound@digitalmars.com> wrote in message news:c9ole4$1m0s$1@digitaldaemon.com... > > "Vathix" <vathix@dprogramming.com> wrote in message news:bukk58$1ip1$1@digitaldaemon.com... > > I'd prefer that it only > > append the \0 at the time of casting to char*, cast overloads are good > > for this; I wonder why they aren't in D. > > There are many times in C where char*'s are not necessarilly 0 terminated, it's just a convention. By forcing this issue in D, unexpected strange bugs can crop up when interoperating with C. Unfortunately, when dealing with C APIs, one always needs to carefully check the documentation for it to see how to correctly pass strings. Win32 APIs are certainly NOT consistent about it. > > |
Copyright © 1999-2021 by the D Language Foundation