[Issue 23476] New: Second ImportC example in Quick Examples, Section 41.1, does not compile
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Nov 11 16:58:34 UTC 2022
https://issues.dlang.org/show_bug.cgi?id=23476
Issue ID: 23476
Summary: Second ImportC example in Quick Examples, Section
41.1, does not compile
Product: D
Version: D2
Hardware: x86_64
OS: FreeBSD
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: donaldcallen1942 at icloud.com
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 at 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));
}
--
More information about the Digitalmars-d-bugs
mailing list