Thread overview | ||||||
---|---|---|---|---|---|---|
|
January 16, 2019 pragma mangle on extern(C) in function body | ||||
---|---|---|---|---|
| ||||
While it is perfectly ok to define an extern(C) function in a function method, I can't seem to get pragma(mangle, "...") on it to work. --- pragma(mangle, "Foo") // Ok extern(C) void foo(); void main() { pragma(mangle, "Bar") // Error.... extern(C) void bar(); } --- Any idea why? |
January 16, 2019 Re: pragma mangle on extern(C) in function body | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sebastiaan Koppe | On Wednesday, 16 January 2019 at 19:41:04 UTC, Sebastiaan Koppe wrote: > While it is perfectly ok to define an extern(C) function in a function method, I can't seem to get pragma(mangle, "...") on it to work. > > --- > pragma(mangle, "Foo") // Ok > extern(C) void foo(); > > void main() { > pragma(mangle, "Bar") // Error.... > extern(C) void bar(); > } > --- > > Any idea why? See also: https://issues.dlang.org/show_bug.cgi?id=15843 https://issues.dlang.org/show_bug.cgi?id=17638 https://issues.dlang.org/show_bug.cgi?id=19149 |
January 16, 2019 Re: pragma mangle on extern(C) in function body | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sebastiaan Koppe | On 1/16/19 2:41 PM, Sebastiaan Koppe wrote:
> While it is perfectly ok to define an extern(C) function in a function method, I can't seem to get pragma(mangle, "...") on it to work.
>
> ---
> pragma(mangle, "Foo") // Ok
> extern(C) void foo();
>
> void main() {
> pragma(mangle, "Bar") // Error....
> extern(C) void bar();
> }
> ---
>
> Any idea why?
I found the same error, not too long ago.
I would note also, the error is not very good:
Error: unrecognized pragma(mangle)
Which is the same error you get if you put any unknown pragma identifier in there.
I'm guessing it's a missed case in the compiler, and not intentionally omitted.
-Steve
|
January 16, 2019 Re: pragma mangle on extern(C) in function body | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | On Wednesday, 16 January 2019 at 19:59:02 UTC, Steven Schveighoffer wrote:
> I'm guessing it's a missed case in the compiler, and not intentionally omitted.
>
> -Steve
The workaround is quite silly. Seems like a parser issue.
---
pragma(mangle, "Foo")
extern(C) void foo();
mixin template T()
{
pragma(mangle, "Bar")
extern(C) void bar();
}
void main() {
mixin T!(); // Hurrah!
}
---
|
Copyright © 1999-2021 by the D Language Foundation