Native shebang: Difference between revisions

m
Corrected compile bug, should run correctly now.
No edit summary
m (Corrected compile bug, should run correctly now.)
Line 72:
===Using gcc to script C===
{{incorrect|C|[[Talk:Native shebang#Problems]]: "The C example doesn't work for me (unless a segmentation fault from script_gcc.sh can be described as "working" or a bad interpreter error from echo.c can be described as "working"). --Rdm" }}
 
I was able to get this functional, by renaming the itoa() function to itoa_() NOTE, there is an itoa() function already. I will also write a 'correct' 2nd version of this example, that does not use a bash helper script (no reason for that). --JimF
 
'''File: script_gcc.c'''
<lang c>#!/usr/local/bin/script_gcc.sh
Line 119 ⟶ 122:
char itoa_out[BUFSIZ];
 
STRING itoaitoa_(int i){
sprintf(itoa_out, "%d", i);
return itoa_out;
Line 173 ⟶ 176:
/* if a CACHEd copy is not to be kept, then fork a sub-process to unlink the .out file */
if(OPT_CACHE == FALSE){
binpath=STRCAT(*dirnamew, "/", argv0_basename, itoaitoa_(getpid()), OEXT, ENDCAT);
if(compile(srcpath, binpath) == EXIT_SUCCESS){
if(fork()){
Anonymous user