I'm using Clang on MacOS. When I compile C with clang
, is there a way to specify -std=c 17
without writing it every time? Is there some sort of a global clang
config file?
CodePudding user response:
alias c ="c -O2 -W -Wall -std=c 17"
You can add something like that to your bashrc or whatever shell you use.
Another thing that should work on MacOS, works on every other unix, would be to create a wrapper script in /usr/local/bin/. Assuming you have that in your $PATH. Otherwise the problem recurses to exetending your PATH.
% cat >> /usr/local/bin/c <<EOF
#!/bin/sh
/usr/bin/c -O2 -W -Wall -std=c 17 "$@"
EOF
% chmod a x /usr/local/bin/c
The cat creates the file and the chmod makes it executable by all. Use the text editor of your choice if you don't understand that cat command.