# Unset CC and CXX environment variables when compiler is set to msvc

**URL:** <https://travis-ci.community/t/unset-cc-and-cxx-environment-variables-when-compiler-is-set-to-msvc/1430>\
**Category:** Windows\
**Created:** [December 14, 2018, 6:44am UTC](https://travis-ci.community/t/unset-cc-and-cxx-environment-variables-when-compiler-is-set-to-msvc/1430 "2018-12-14T06:44:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![k0ekk0ek](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/k0ekk0ek/32/1846_2.png) [@k0ekk0ek](https://travis-ci.community/u/k0ekk0ek)\
**Post date:** [December 14, 2018, 6:44am UTC](https://travis-ci.community/t/unset-cc-and-cxx-environment-variables-when-compiler-is-set-to-msvc/1430/1 "2018-12-14T06:44:34Z")

</div>

Maybe a good one for the future. If “compiler:” is set to something like msvc on Windows, consider unsetting CC and CXX. For automatically detecting the compiler version in (at least) Conan ([https://conan.io](https://conan.io)) the environment variables get in the way. i.e. Conan detects gcc. Even setting the environment variable CC to cl.exe does not work. I’m not sure if automatic detection works as expected in for example CMake. I currently just work around it by unsetting the variables if os.

---

<div class="post-metadata">

**Author:** ![solvingj](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/solvingj/32/151_2.png) [@solvingj](https://travis-ci.community/u/solvingj)\
**Post date:** [December 31, 2018, 7:32am UTC](https://travis-ci.community/t/unset-cc-and-cxx-environment-variables-when-compiler-is-set-to-msvc/1430/2 "2018-12-31T07:32:43Z")

</div>

I agree, it’s very confusing that my travis.yml says this:

```
    language: c
    matrix:
    include:
        # Windows x64 builds (MSVC)
        - os: windows
          env: CC=CL.exe CXX=CL.exe

```

and my log says this:

```
Setting environment variables from .travis.yml
$ export CC=CL.exe
$ export CXX=CL.exe
$ export TRAVIS_COMPILER=gcc
$ export CC=gcc
$ export CC_FOR_BUILD=gcc
$ gcc --version
```

---

<div class="post-metadata">

**Author:** ![raub](https://avatars.discourse-cdn.com/v4/letter/r/839c29/32.png) [@raub](https://travis-ci.community/u/raub)\
**Post date:** [January 7, 2019, 9:23am UTC](https://travis-ci.community/t/unset-cc-and-cxx-environment-variables-when-compiler-is-set-to-msvc/1430/3 "2019-01-07T09:23:06Z")

</div>

Hey, I guess it’s late, but [this](https://docs.travis-ci.com/user/languages/cpp/#c11c11-and-beyond-and-toolchain-versioning) might help. Basically:

```auto
matrix:
  include:
    - os: Windows
      # ...
      env:
         - MATRIX_EVAL="CC=CL.exe && CXX=CL.exe"
# ...
before_install:
    - eval "${MATRIX_EVAL}"

```
