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

support for inline C++ header (analog to cgo for go) #97

Open
timotheecour opened this issue Feb 2, 2018 · 0 comments
Open

support for inline C++ header (analog to cgo for go) #97

timotheecour opened this issue Feb 2, 2018 · 0 comments

Comments

@timotheecour
Copy link
Collaborator

timotheecour commented Feb 2, 2018

  • NOTE: go has some form of this feature (but of course limited to C: https://golang.org/cmd/cgo/); there's an opportunity to do this much more elegantly
  • eg use cases: would simplify writing tests, which wouldn't have to carry around separate headers; makes scripting easier

eg syntax:

module main;

enum header=`
#include <stdio.h>
inline void fun(){printf("hello world\n");}
`;

pragma(modmapFromString, header);

import(C++) _:fun;
void main(){fun;}

how hard would that be to implement?

cc @marler8997
EDIT: maybe HAR could be used here, allowing to use multiple files, eg:

module main;

enum har_header=`
--- util.h
#include <stdio.h>
void fun();
--- util.cpp
void fun(){printf("hello world\n");}
`;
pragma(modmapFromString, har_header);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant