Skip to content

Instantly share code, notes, and snippets.

@Laeeth
Created February 22, 2018 17:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Laeeth/9a51e12ce7273bf1ded322d5fb12ab18 to your computer and use it in GitHub Desktop.
Save Laeeth/9a51e12ce7273bf1ded322d5fb12ab18 to your computer and use it in GitHub Desktop.
extern(C) register passing bug
#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;
}
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