I'm using the following function in my spike-webserver:
object compileit(string file, void|int quiet) { object prog; if (!quiet) log("Compiling %s", file); if (mixed err = catch(prog = compile_file(file)())) log(LOG_ERR, "Compile error %s", describe_backtrace(err)); return prog; }
in order to compile modules. I'd like two things though, which currently don't quite work as I had hoped:
a. When there is a compilation problem, I get a backtrace here, but it does not reveal what compilation error occurred (it does not show line number and diagnostics). Any suggestions how to get those?
b. I'd like a (list of) custom library directories which I want to include in the namespace, without having to specify them on the commandline using -L options. How can this be accomplished?
You could make your own compile handler. Look at compile_string() in hilfe_compile.
Hi Stephen-
As you’ve discovered, when compilation fails, the backtrace only shows you that a compilation error occurred at the point where you tried to compile. In order to get the errors from the compiler, you’ll need to pass it a delegate that it will report the problems too.
If you look for the class ErrorContainer and its uses, you can see one way to get a list of errors/warnings by line and file when compiling:
https://git.sr.ht/~hww3/caudium/tree/master/server/base_server/caudiumloader...
Hope this helps!
Bill
On Jun 7, 2020, at 1:41 PM, Stephen R. van den Berg srb@cuci.nl wrote:
I'm using the following function in my spike-webserver:
object compileit(string file, void|int quiet) { object prog; if (!quiet) log("Compiling %s", file); if (mixed err = catch(prog = compile_file(file)())) log(LOG_ERR, "Compile error %s", describe_backtrace(err)); return prog; }
in order to compile modules. I'd like two things though, which currently don't quite work as I had hoped:
a. When there is a compilation problem, I get a backtrace here, but it does not reveal what compilation error occurred (it does not show line number and diagnostics). Any suggestions how to get those?
b. I'd like a (list of) custom library directories which I want to include in the namespace, without having to specify them on the commandline using -L options. How can this be accomplished? -- Stephen.
pike-devel@lists.lysator.liu.se