Created
November 1, 2023 13:37
-
-
Save Pixailz/8f0c8044868c40aca89b354248bb7af8 to your computer and use it in GitHub Desktop.
Get gcc / clang, in C or C++, information
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
declare -a includes | |
function get_includes() | |
{ | |
local compiler="${1:-gcc}" | |
local language="${2:-c}" | |
local data beg_inc end_inc | |
data="$(echo | "${compiler}" -x${language} -v -E - 2>&1)" | |
beg_inc="$(<<< ${data} grep -n '<...> search starts here:' | cut -f1 -d':')" | |
end_inc="$(<<< ${data} grep -n 'End of search list.' | cut -f1 -d':')" | |
includes+=($(<<< ${data} sed -n "$((beg_inc + 1)),$((end_inc - 1))p")) | |
} | |
get_includes "gcc" | |
get_includes "clang" | |
get_includes "cc" | |
includes=($(tr ' ' '\n' <<<${includes[@]} | sort -u )) | |
echo Includes : | |
printf -- "- %s\n" ${includes[@]} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment