Skip to content

Commit

Permalink
Merge pull request #336 from hahnjo/executable-pointer
Browse files Browse the repository at this point in the history
executable: Fix passing pointers to functions
  • Loading branch information
JohanMabille committed May 15, 2020
2 parents 231eafd + 7dfda66 commit 37be27a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/xmagics/executable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,16 @@ namespace xcpp
unique_fn += "return 0;\n";
unique_fn += "}";

// This code is unloaded after the executable has been generated.
main = "int main() {\n";
main += "return " + fn_name + "();\n";
main += "}\n";
// Define the function that is called for checking any pointer used
// as a member base or passed to a function call. This avoids pulling
// in the full libcling.so which is not needed.
main += "void *cling_runtime_internal_throwIfInvalidPointer(\n";
main += " void *, void *, const void *Arg) {\n";
main += " return const_cast<void*>(Arg);\n";
main += "}";
return main;
}
Expand Down

0 comments on commit 37be27a

Please sign in to comment.