Closed SimonN closed 1 year ago
Typical violation:
R al_foo(in X* x);
Here, X
can be void
, int
, char
, ALLEGRO_USTR
, ...
With what should we replace in X*
? I believe it should be const(X)*
because C is happy when we forward-declare a function with parameter const X*
and implement it using const X const*
. Or do you have other ideas?
Yes, I think const(X)*
is most appropriate. Technically D's const
is transitive and C's const
is head-const, so I don't know precisely whether using D's const
for C bindings is even appropriate, but it's probably fine since we're dealing with opaque and primitive types here.
Thanks for looking into this.
DAllegro5 4.0.4 for Allegro 5.2.0
The D keyword
in
for function parameters meansscope const ref
and DMD 2.104.0, released 2023-06-01, is beginning to warn about usingin
duringextern(C)
. More information:DMD 2.104.0 Release Notes: Using in parameters with non extern(D)/extern(C++) functions is deprecated
DMD 2.101.0 Release Notes: -preview=in disabled for non-D-non-C++ linkage:
in
"is D centric, as it is an enhanced version ofscope const ref
. As non-extern(D) functions usually are expected to match a specific ABI, usingin
is hardly a good idea."Using DMD 2.104.0, DAllegro5 now builds with many warnings: