Why does the importC example not compile?
kdevel
kdevel at vogtner.de
Fri Jan 13 11:10:23 UTC 2023
https://dlang.org/spec/importc.html
`square.c`
```
int square(int i)
{
return i * i;
}
```
`demo.d`
```
import std.stdio;
import square;
void main()
{
int i = 7;
writefln("The square of %s is %s", i, square(i));
}
```
```
$ dmd --version
DMD64 D Compiler v2.101.1
Copyright (C) 1999-2022 by The D Language Foundation, All Rights
Reserved written by Walter Bright
$ dmd demo.d square.c
demo.d(6): Error: function expected before `()`, not `module
square` of type `void`
```
I would have expected that each and every piece of code in the
documentation is automatically compiled with any new compiler
release.
More information about the Digitalmars-d-learn
mailing list