Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can't include #include <caml/memory.h> #251

Open
FraMecca opened this issue Apr 6, 2020 · 3 comments
Open

can't include #include <caml/memory.h> #251

FraMecca opened this issue Apr 6, 2020 · 3 comments

Comments

@FraMecca
Copy link

FraMecca commented Apr 6, 2020

#include <stdio.h>
#include <assert.h>

// #include <caml/alloc.h>                                                                                                                                                    
// #include <caml/mlvalues.h>                                                                                                                                                 
#include <caml/memory.h>
// #include <caml/callback.h>                                                                                                                                                 


import std.stdio: writeln;

void ocaml_test_return_string() {
    CAMLlocal1(res);
}

void main(string[] argv)
{
    writeln(argv);
}
$ d++ main.dpp
Error: Could not execute `dmd main.d -ofmain`:
main.d(7282): Error: found `int` when expecting `;` following statement
@atilaneves atilaneves added the bug label Apr 6, 2020
@Laeeth
Copy link

Laeeth commented Jun 23, 2020

I don't know about this one as a while since I looked at. But i figured out what problematic macros were doing and then just rewrote the code inline or as a template - don't quite remember but a working trivial example of caml calling D is up on code.dlang.org I think. I didn't take it any further.

@Laeeth
Copy link

Laeeth commented Jun 23, 2020

AST to AST translation for C to D would be nice. It's not that bad although quite a lot of work. See c2rust

@atilaneves
Copy link
Owner

Macros are... hard. In this case there's two issues: one is the non-standard __attribute__((unused)) that causes the original error, but even removing it manually causes another issue which is that the CALxparam1 macro uses the result of a comma expression, which is now illegal in D. I don't think this is fixable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants