c3c icon indicating copy to clipboard operation
c3c copied to clipboard

`compile-run` does not accept arguments to pass to the run program.

Open rexim opened this issue 1 year ago • 1 comments

The current signature of it is compile-run <file1> [<file2> ...] and according to the implementation of run_after_compile it indeed does not accept any additional arguments to pass to the program: https://github.com/c3lang/c3c/blob/8d6dabf65c6df420b9030bc049f5ce3092cec01c/src/compiler/compiler.c#L622-L680

Are there any plans on allowing passing the arguments? Something akin to compile-run <file1> [<file2> ...] [-- <arg1> [<arg2> ...]]? If so may I implement it? :)

rexim avatar Jul 30 '24 11:07 rexim

I've thought of adding it several times but never got around to it. If you want to implement it, you're very welcome to do so. If you do, then try to add running it on at least one of the CI runs, so that we catch any regressions. And keep in mind that it needs separate testing for MSVC and other platforms (Linux and MacOS behaves the same here)

lerno avatar Jul 30 '24 11:07 lerno

Btw, is it okay if I use subprocess.h instead of system()? std::io::process is already based on it, so we already kinda have it in the codebase, it's just not usable in the compiler itself :D Is it okay to add such dependency?

rexim avatar Aug 01 '24 19:08 rexim

I'll probably look at subprocess.h and then grab exactly the parts we want and then make a slimmed down version of that eventually, but yes, you can do that.

lerno avatar Aug 01 '24 19:08 lerno

Just check that it's ok to add it to the codebase in terms of copyright and such.

lerno avatar Aug 01 '24 19:08 lerno

By the way, I saw you had some problems linking the non-RTTI version with wrapper.cpp. I think I've updated the CMake file correctly to deal with this (sending -fno-rtti on linux and /GR- on windows) BUT most of the precompiled LLVM are with RTTI, so the CI doesn't really tell me if it worked correctly or not. You might have fixed this in your local branch already anyway, but I'l just telling you in case you try master and it's trying to overwrite your stuff and then it doesn't work anyway...

lerno avatar Aug 01 '24 19:08 lerno