Consider the hello world C program:
hello.c:
#include \"stdio.h\" int main() { printf(\"Hello, World!\\n\"); }
For oneline lovers:
echo "int main(void) {}" | gcc -o /dev/null -v -x c - &> /dev/stdout| grep collect | tr -s " " "\012"
Replace -x c with -x c++ to get c++ flags.
-x c
-x c++
Can be used also with clang, but in such case you should grep for /usr/bin/ld
/usr/bin/ld