I'm building a little interpreter-like bash shell script to easily run C++ files from the command line. You can see the source code here: https://github.com/binarez/xcpp/blob/master/xcpp.sh. The source files used by my system are .xcpp just to differenciate them from regular cpp files.
It all works pretty good, except when I try to include a xcpp file from another xcpp file : the gcc pre-processor tries to interpret #!, which is the beginning of the shebang line I use to start up my bash script when I run xcpp files.
Note that it works on the "main" file because I use sed to skip over the shebang line before pumping it to gcc but it doesn't work on #include'd file because I don't have a chance to run sed on that included file before the preprocessor processes it.
Exemple of the "main" script test.xcpp:
#!./xcpp.sh
#include "module.xcpp"
int test( strings & args )
{
module( args );
return 0;
}
Exemple of module.xcpp:
#!./xcpp.sh
int module( strings & args )
{
for( string & arg : args )
{
println(arg);
}
return 0;
}
With this system, you can just chmod +x test.xcpp and run it with ./test.xcpp
I want to be able to also run module.xcpp as a "main" script AND use it within other xcpp scripts. I'm using gcc. How can I make it work?
The error I get:
module.xcpp:1:2: error: invalid preprocessing directive #!
#!xcpp.sh