htod - convert C .h files to D import files

BCS BCS_member at pathlink.com
Thu May 25 08:56:30 PDT 2006


In article <1xu5l9je8ge3f.txbccq4m8i7m.dlg at 40tude.net>, Derek Parnell says...
>
>On Wed, 24 May 2006 14:15:43 -0700, BCS wrote:
>>
[...]
>>
>
>But if that happened, things lke concatenation would cause problems.
>
>#define FOO "foo"
>#define BAR "bar"
>   |
>   |
>   V
>const char[] FOO = "foo\0"; //explicitly null terminate
>const char[] BAR = "bar\0"; //explicitly null terminate
>
>. . .
>
>  char[] x = FOO ~ BAR; // Now it has an embedded \0 !
>
>-- 

I'll grant that. I think this will be another case of there being no 1-to-1
correspondence from C to D. I expect that with char constants, they are more
likely to get copied than concatenated. The work around for either is easy as
long as you remember it.

Char[] foo = "bar", copy; copy = bar ~ \0; \\cat copies

Char[] foo = "bar\0"
bing = "baz\0", copy; copy = bar[0..$-1] ~ bing ; \\cat copies






More information about the Digitalmars-d-announce mailing list