On Thursday, 31 August 2023 at 18:42:57 UTC, Richard (Rikki) Andrew Cattermole wrote:
```d
extern(C) int main()
{
    import core.stdc.stdio;

    string hello = "hello";
    printf(hello.ptr);

    return 0;
}
```

1) You forgot to import ``core.stdc.stdio``
2) String literal is of type string (which is an alias to ``immutable(char)[]``). 3) A slice is a pointer + length, and C doesn't understand slices, so you must explicitly pass in the pointer from the slice (the compiler would do this for you if you had the literal in the arguments list instead of the variable).

```d
import core.stdc.stdio;
```

This generates ``` Error: undefined identifier `size_t` ```.
  • I don't understa... confused via Digitalmars-d-learn
    • Re: I don't... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
      • Re: I d... confused via Digitalmars-d-learn
        • Re:... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
          • ... confused via Digitalmars-d-learn
            • ... bachmeier via Digitalmars-d-learn
              • ... confused via Digitalmars-d-learn
                • ... bachmeier via Digitalmars-d-learn
            • ... evilrat via Digitalmars-d-learn
              • ... confused via Digitalmars-d-learn
                • ... Jonathan M Davis via Digitalmars-d-learn
                • ... confused via Digitalmars-d-learn
                • ... evilrat via Digitalmars-d-learn

Reply via email to