Created
February 22, 2018 17:28
-
-
Save Laeeth/9a51e12ce7273bf1ded322d5fb12ab18 to your computer and use it in GitHub Desktop.
extern(C) register passing bug
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
#include <stdio.h> | |
struct Foo | |
{ | |
double a; | |
void *p; | |
}; | |
extern "C" Foo foo2(Foo foo, double a, double b, double c) | |
{ | |
printf("a=%f, b=%f, c=%f\n\n",a,b,c); | |
Foo fo {1.0,0L}; | |
return fo; | |
} | |
extern "C" Foo foo() | |
{ | |
Foo fo {1.0,0L}; | |
return fo; | |
} | |
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
import std.stdio; | |
struct Foo | |
{ | |
double a; | |
void *p; | |
} | |
extern(C) Foo foo(); | |
extern(C) Foo foo2(Foo foo, double a,double b, double c); | |
void main(string[] args) | |
{ | |
auto f = foo(); | |
writeln(f); | |
auto f2 = foo2(f,1.0,2.0,3.0); | |
writeln(f2); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment