On 22-06-2016 22:06:53 +0200, Michał Górny wrote:
> +# @FUNCTION: tc-get-compiler-type
> +# @RETURN: keyword identifying the compiler: gcc, clang, unknown
> +tc-get-compiler-type() {
> +     set -- $($(tc-getCPP "$@") -E -P - <<<"CPP_WORKS __GNUC__ __clang__")

% echo "CPP_WORKS __GNUC__ __clang__" | clang -E -P  - 
CPP_WORKS 4 1

The logic below does the right thing, but it might be good for future
reference to make note of this (clang).

> +
> +     # CPP_WORKS shouldn't be substituted -- so if it's not there,
> +     # cpp is probably broken
> +     if [[ $1 != CPP_WORKS ]]; then
> +             echo unknown
> +     # Check which of the defines were substituted
> +     elif [[ $3 != __clang__ ]]; then
> +             echo clang
> +     elif [[ $2 != __GNUC__ ]]; then
> +             echo gcc
> +     else
> +             echo unknown
> +     fi
> +}

-- 
Fabian Groffen
Gentoo on a different level

Attachment: signature.asc
Description: Digital signature

Reply via email to