D as a Better C

Azi Hassan via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Fri Sep 1 15:26:04 PDT 2017


On Wednesday, 30 August 2017 at 22:48:45 UTC, Adam D. Ruppe wrote:
> On Wednesday, 30 August 2017 at 22:22:23 UTC, Azi Hassan wrote:
>> extern(C) int main(int argc, char*[] argv, char*[] env)
>
> That's a D array of pointers. A D array is larger than a C 
> "array" argument, thus you're skipping past it.
>
> The correct declaration is (int argc, char** argv, char** env).
>
> (I'd argue that is the correct way to write it in C too, that's 
> how I always do and it works there. But I just loathe C's 
> arrays anyway.)

Brilliant, thanks ! I just re-read the blog post and it uses the 
char** syntax too, but I didn't pay attention to it.


More information about the Digitalmars-d-announce mailing list