alexandru-dinu / igcc

Interactive GCC - C/C++ REPL.
GNU General Public License v3.0
191 stars 12 forks source link

Differentiate between C and C++ support #10

Open alexandru-dinu opened 3 years ago

alexandru-dinu commented 3 years ago

Make explicit:

Artoria2e5 commented 1 year ago

This compiler_cmd thing seems simple to adapt into clang. Maybe igcc can allow people to define multiple sets of these configs, like:

default:
  prompt: "igcc> "
  compiler_cmd: "g++ -x c++ -std=c++17 -Wall -o $outfile - $include_dirs $lib_dirs $libs"
  include_dir_cmd: "-I$cmd"
  lib_dir_cmd: "-L$cmd"
  lib_cmd: "-l$cmd"
c21:
  prompt: "c21> "
  compiler_cmd: "g++ -x c++ -std=gnu2x -Wall -o $outfile - $include_dirs $lib_dirs $libs"
clang:
  compiler_cmd: "clang++ -x c++ -std=c++17 -Wall -o $outfile - $include_dirs $lib_dirs $libs"

(The intention is to let missing values fall back onto the default.)

And then define a .c command or something to switch compilers. The default boilerplate can use some #ifdef __cplusplus too.


While we are at the compiler_cmd topic, another thing: I don't like the config.compiler_cmd.split() because it feels like the wrong way to parse command lines, but also there's almost no chance for people to put anything that require spaces in these strings. Ah just leave it be.