On Friday, 13 January 2023 at 12:46:33 UTC, Dennis wrote:
On Friday, 13 January 2023 at 12:33:28 UTC, kdevel wrote:
What must be added or changed in order to test every example which is intended to produce an executable?

Support for separate compilation / ImportC would need to be added to dspec_tester:
https://github.com/dlang/dlang.org/blob/master/tools/dspec_tester.d

I ran into this issue too, what I discovered is that when you import `square`, it is importing the file `square.c` (if one exists).

Because you have a function called `square` in a file called `square`, confusingly, you want `square.square`. Hence the error message about trying to invoke parens `()` on a module.

If you rename the file to `my_c_funcs.c` and then you do:

```d
import std.stdio;
import my_c_funcs;

void main()
{
        int i = 7;
        writefln("The square of %s is %s", i, my_c_funcs.square(i));
}
```

```sh
(dmd-nightly)[user@MSI source]$ dmd app.d my_c_funcs.c
(dmd-nightly)[user@MSI source]$ ./app
The square of 7 is 49
```

Reply via email to