Bug 23476 – Second ImportC example in Quick Examples, Section 41.1, does not compile
Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P3
Component
dlang.org
Product
D
Version
D2
Platform
All
OS
All
Creation time
2022-11-11T16:58:34Z
Last change time
2023-04-09T06:39:33Z
Keywords
ImportC
Assigned to
No Owner
Creator
Don Allen
Comments
Comment #0 by donaldcallen1942 — 2022-11-11T16:58:34Z
Compiling the example verbatim with either the released version of DMD or the current release candidate produces the following:
(dmd-2.101.0-rc.1)dca@giovanni:/tmp$ dmd demo.d square.c
demo.d(6): Error: function expected before `()`, not `module square` of type `void`
This is due to the name conflict between the C module and the function it contains. Fully qualifying the function name in the D code fixes it:
import std.stdio;
import square;
void main()
{
int i = 7;
writefln("The square of %s is %s", i, square.square(i));
}