Last active
February 23, 2025 06:24
-
-
Save jasonroelofs/6453cc270ab8c60fca72029b47e6f7d7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/bin/bash | |
set -ex | |
PREFIX=[where ruby is installed] | |
clang++ -I$PREFIX/include/ruby-3.4.0/arm64-darwin24 -I$PREFIX/include/ruby-3.4.0 -L$PREFIX/lib -lruby.3.4 test.cpp |
This file contains hidden or 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 <ruby.h> | |
// This SEGFAULTs | |
int main(int argc, char** argv) | |
{ | |
ruby_init(); | |
ruby_init_loadpath(); | |
char* options[] = { "-e;" }; | |
ruby_options(2, options); | |
} |
This file contains hidden or 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 <ruby.h> | |
// This does not! | |
int main(int argc, char** argv) | |
{ | |
RUBY_INIT_STACK; | |
ruby_init(); | |
ruby_init_loadpath(); | |
char* options[] = { "-e;" }; | |
ruby_options(2, options); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Not adding NULL at first options?
char* options[] = {NULL, "-e;" }; ruby_options(2, options);
Here this is not ok:
char* options[] = {"-e;" }; ruby_options(2, options);