Skip to content
This repository has been archived by the owner on Mar 4, 2019. It is now read-only.

Passing command line arguments #44

Open
TransGirlCodes opened this issue Nov 8, 2017 · 1 comment
Open

Passing command line arguments #44

TransGirlCodes opened this issue Nov 8, 2017 · 1 comment

Comments

@TransGirlCodes
Copy link

Hi,

I've just tried to make a binary which accepts command line arguments and I get segfaults which has led me to notice:

In hello.jl:

Base.@ccallable function julia_main(ARGS::Vector{String})::Cint
    println("hello, world")
    @show f()
    println(lineplot(1:10, (1:10).^2))
    return 0
end

So I should expect to accept ARGS and pass it through to use with say ArgParse.jl.
However, when I look at program.c:

int main(int argc, char *argv[])
{
    intptr_t v;

    // Initialize Julia
    uv_setup_args(argc, argv); // no-op on Windows
    libsupport_init();
    jl_options.image_file = "libhello";
    julia_init(JL_IMAGE_CWD);

    // Do some work
    julia_main();

    // Cleanup and graceful exit
    jl_atexit_hook(0);
    return 0;
}

Nothing is passed to julia_main when it is invoked - perhaps why I'm getting segfault!? So does the call of julia_main() need to be altered to accept some arguments? If so, how?

@TransGirlCodes
Copy link
Author

I've just had a look in procram2.c and have seen that it converts UTF16 to UTF8 and builds an array of strings, for passing into julia_main, is this ok to simply copy into program.c (including the conditional windows dependent bit)?

(I know program2 is supposed to do somethings differently to program one regarding including a binary rather than loading a dl (although I can't see where). So I'm hesitant to just blindly copy anything in program2.c.)

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

No branches or pull requests

1 participant