-
-
Notifications
You must be signed in to change notification settings - Fork 606
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix Issue 23045 - importC: casted function type is missing extern(C) (#…
- Loading branch information
1 parent
893c477
commit 84af0a8
Showing
2 changed files
with
34 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* https://issues.dlang.org/show_bug.cgi?id=23045 | ||
*/ | ||
|
||
int printf(const char *s, ...); | ||
void exit(int); | ||
|
||
void assert(int b, int line) | ||
{ | ||
if (!b) | ||
{ | ||
printf("failed test %d\n", line); | ||
exit(1); | ||
} | ||
} | ||
|
||
void other(int a, int b) | ||
{ | ||
printf("a=%d b=%d\n", a, b); | ||
assert(a == 1, "1"); | ||
assert(b == 2, "2"); | ||
} | ||
|
||
int main() | ||
{ | ||
// called like extern(D) | ||
((void (*)(int, int))other)(1, 2); | ||
|
||
// Error: incompatible types for `(cast(void function(int, int))& other) is (other)`: `void function(int, int)` and `extern (C) void(int a, int b)` | ||
if (((void (*)(int, int))other) == other) | ||
{ } | ||
|
||
return 0; | ||
} |