Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Color output of compiler warnings and errors show incorrectly in Output panel and are not parsed for Problems panel #2278

Closed
reedhedges opened this issue Dec 4, 2021 · 2 comments
Labels
duplicate a duplicate of an already present issue enhancement an enhancement to the product that is either not present or an improvement to an existing feature Feature: build

Comments

@reedhedges
Copy link

Hello, I'm not sure if this is an issue with CMake tools, or something else (vscode's Terminal? I've tried both "internal" and "external" settings), so if anyone has any suggestions for investigating further to narrow down what's actually happening, it would be appreciated.

When I build, compiler errors and warnings are not being displayed correctly in the Output pane, and Problems doesn't pick them up at all. The terminal escape codes for color are not working correctly (see output below).

I am on Linux, and have set "Unix Makefiles" as preferred generator. I normally leave the compiler setting unspecified for cmake tools, but have also set gcc and clang versions (kits) with same results. I have the standard "C/C++" extension installed, along with "C/C++ Themes", "CMake" some others, but disabled all of those with the same results.

[main] Building folder: cmake_example 
[main] Configuring folder: cmake_example 
[proc] Executing command: /usr/bin/cmake --no-warn-unused-cli -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_BUILD_TYPE:STRING=Debug -H/home/reed/examples-tutorials-tests/cmake_example -B/home/reed/examples-tutorials-tests/cmake_example/build -G "Unix Makefiles"
[cmake] Not searching for unused variables given on the command line.
[cmake] -- The CXX compiler identification is GNU 10.3.0
[cmake] -- Detecting CXX compiler ABI info
[cmake] -- Detecting CXX compiler ABI info - done
[cmake] -- Check for working CXX compiler: /usr/bin/c++ - skipped
[cmake] -- Detecting CXX compile features
[cmake] -- Detecting CXX compile features - done
[cmake] -- ccache found and enabled
[cmake] -- Configuring done
[cmake] -- Generating done
[cmake] -- Build files have been written to: /home/reed/examples-tutorials-tests/cmake_example/build
[cmakefileapi-driver] This version of CMake does not support the "toolchains" object kind. Compiler paths will be determined by reading CMakeCache.txt.
[build] Starting build
[proc] Executing command: /usr/bin/cmake --build /home/reed/examples-tutorials-tests/cmake_example/build --config Debug --target all -j 6 --
[build] Scanning dependencies of target example
[build] [ 50%] Building CXX object CMakeFiles/example.dir/example.cc.o
[build] �[01m�[K/home/reed/examples-tutorials-tests/cmake_example/example.cc:�[m�[K In function ‘�[01m�[Kint main()�[m�[K’:
[build] �[01m�[K/home/reed/examples-tutorials-tests/cmake_example/example.cc:15:6:�[m�[K �[01;35m�[Kwarning: �[m�[Kignoring return value of ‘�[01m�[Kint foo(char, int)�[m�[K’, declared with attribute ‘�[01m�[Knodiscard�[m�[K’ [�[01;35m�[K-Wunused-result�[m�[K]
[build]    15 |   �[01;35m�[Kfoo(x, c)�[m�[K;
[build]       |   �[01;35m�[K~~~^~~~~~�[m�[K
[build] �[01m�[K/home/reed/examples-tutorials-tests/cmake_example/example.cc:6:19:�[m�[K �[01;36m�[Knote: �[m�[Kdeclared here
[build]     6 | [[nodiscard]] int �[01;36m�[Kfoo�[m�[K(char c, int x)
[build]       |                   �[01;36m�[K^~~�[m�[K
[build] �[01m�[K/home/reed/examples-tutorials-tests/cmake_example/example.cc:16:3:�[m�[K �[01;31m�[Kerror: �[m�[K‘�[01m�[Kbar�[m�[K’ was not declared in this scope
[build]    16 |   �[01;31m�[Kbar�[m�[K(x);
[build]       |   �[01;31m�[K^~~�[m�[K
[build] �[01m�[K/home/reed/examples-tutorials-tests/cmake_example/example.cc:17:10:�[m�[K �[01;31m�[Kerror: �[m�[Kinvalid conversion from ‘�[01m�[Kconst char*�[m�[K’ to ‘�[01m�[Kint�[m�[K’ [�[01;31m�[K-fpermissive�[m�[K]
[build]    17 |   return �[01;31m�[K"hello world"�[m�[K;
[build]       |          �[01;31m�[K^~~~~~~~~~~~~�[m�[K
[build]       |          �[01;31m�[K|�[m�[K
[build]       |          �[01;31m�[Kconst char*�[m�[K
[build] gmake[2]: *** [CMakeFiles/example.dir/build.make:82: CMakeFiles/example.dir/example.cc.o] Error 1
[build] gmake[1]: *** [CMakeFiles/Makefile2:95: CMakeFiles/example.dir/all] Error 2
[build] gmake: *** [Makefile:103: all] Error 2
[build] Build finished with exit code 2

CMake Tools Diagnostics

{
  "os": "linux",
  "vscodeVersion": "1.62.3",
  "cmtVersion": "1.9.2",
  "configurations": [
    {
      "folder": "/home/reed/examples-tutorials-tests/cmake_example",
      "cmakeVersion": "3.18.4",
      "configured": true,
      "generator": "Unix Makefiles",
      "usesPresets": false,
      "compilers": {
        "CXX": "/usr/bin/c++"
      }
    }
  ],
  "cpptoolsIntegration": {
    "isReady": true,
    "hasCodeModel": true,
    "activeBuildType": "Debug",
    "buildTypesSeen": [
      "Debug"
    ],
    "requests": [],
    "responses": [],
    "partialMatches": [],
    "targetCount": 1,
    "executablesCount": 1,
    "librariesCount": 0,
    "targets": [
      {
        "name": "example",
        "type": "EXECUTABLE"
      }
    ]
  },
  "settings": [
    {
      "communicationMode": "automatic",
      "useCMakePresets": "auto",
      "configureOnOpen": true
    }
  ]
}

Thanks!

@reedhedges
Copy link
Author

Update, I've looked more into my CMakeLists.txt and discovered it included some CMake configuration I copied from another source which added some compiler options to configure color output (-fcolor-diagnostics for Clang and -fdiagnostics-color=always for GCC.) Removing these fixed the problem. When run by cmake tools, there was no color output and it was able to parse the output just fine, but when I build from a terminal it does turn on color output. I have no idea why this third party cmake configuration turned those on, probably to see color output for another IDE. So I wonder if there's a way to get color output in the "Output" panel in vscode? I'll updated the title of this issue slightly.

@reedhedges reedhedges changed the title Compiler warning and error output formatting problem, Problems window not showing errors and warnings. Color output of compiler warnings and errors show incorrectly in Output panel and are not parsed for Problems panel Dec 4, 2021
@bobbrow
Copy link
Member

bobbrow commented Dec 6, 2021

Thanks for reporting this issue. We've determined that it is a duplicate of #478 so we will close this one and ask that you track that issue instead.

@bobbrow bobbrow added enhancement an enhancement to the product that is either not present or an improvement to an existing feature Feature: build duplicate a duplicate of an already present issue labels Dec 6, 2021
@bobbrow bobbrow closed this as completed Dec 28, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Feb 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
duplicate a duplicate of an already present issue enhancement an enhancement to the product that is either not present or an improvement to an existing feature Feature: build
Projects
None yet
Development

No branches or pull requests

2 participants