Re: Why does the importC example not compile?
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 ```
Re: Why does the importC example not compile?
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
Re: Why does the importC example not compile?
On Friday, 13 January 2023 at 12:20:23 UTC, Dennis wrote: I don't think there's a way to test examples of separate compilation in the spec currently. What must be added or changed in order to test every example which is intended to produce an executable?
Re: Why does the importC example not compile?
Thanks for reporting this. PR: https://github.com/dlang/dlang.org/pull/3489 On Friday, 13 January 2023 at 11:10:23 UTC, kdevel wrote: I would have expected that each and every piece of code in the documentation is automatically compiled with any new compiler release. Individual D snippets can be tested when given the right DDoc macro, such as `SPEC_RUNNABLE_EXAMPLE_RUN` or `SPEC_RUNNABLE_EXAMPLE_FAIL`. (Thanks to Nick Treleaven for adding it to many examples that didn't have it before!) I don't think there's a way to test examples of separate compilation in the spec currently.
Re: Why does the importC example not compile?
try to rename function to distinguish from source module