microsoft / microsoft/vscode-cpptools
User-defined literal operators are not accepted when using Espressif’s xtensa-esp32-elf-gcc version 13.2.0
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 6.2k
- Forks
- 1.7k
- Avg merge
- 14h 46m
- Merged PRs (30d)
- 61
Description
Environment
- OS and Version: Debian 12.7
- VS Code Version: 1.93.1
- C/C++ Extension Version: v1.22.3 (pre-release)
- CMake Tools Extension Version: v1.20.6 (pre-release)
- GCC version:
xtensa-esp-elf-g++ (crosstool-NG esp-13.2.0_20240530) 13.2.0(the one that gets installed by Espressif’s ESP-IDF v5.3.1)
Bug Summary and Steps to Reproduce
Bug Summary:
User-defined literal operators are not accepted by the C/C++ Extension:
This issue is similar to #7034, but the solution implemented back then apparently is not working anymore. @Colengms wrote:
“However, this compiler returns xtensa-esp32-elf-gcc for -dumpmachine, which we are not handling. We could possibly handle this by considering any occurrences of 32 and 64 within the target string instead of giving up.”
My xtensa-esp32-elf-gcc in version 13.2.0 is now returning just xtensa-esp-elf for -dumpmachine which may explain why the same bug appears again.
Steps to reproduce:
cd
mkdir esp
cd esp
git clone -b v5.3.1 --recursive https://github.com/espressif/esp-idf.git
cd esp-idf
./install.sh esp32
. export.sh
cd
mkdir temp
cd temp
printf "cmake_minimum_required(VERSION 3.16)\ninclude(\$ENV{IDF_PATH}/tools/cmake/project.cmake)\nproject(myproject)" > CMakeLists.txt
mkdir main
cd main
printf "idf_component_register(SRCS \"main.cpp\")" > CMakeLists.txt
printf "#include <cstddef>\n\nconstexpr int operator\"\"_lit(char const* s, size_t) {\n return 0;\n}" > main.cpp
cd ..
code .
Now let the CMake Extension configure the project (select “[Unspecified]” for the kit) and open the file main/main.cpp. You should see the error.
Note: . export.sh sets environment variables. VSCode must be started from the terminal while these environment variables are active.
Configuration and Logs
I’m using CMake Tools as the C/C++ configuration provider.
C/C++ Extension Log:
loggingLevel: Information
Custom configuration provider 'CMake Tools' registered
cpptools version (TypeScript): 1.22.3
cpptools version (native): 1.22.3.0
Autocomplete is enabled.
Error squiggles are enabled if all header dependencies are resolved.
Hover is enabled.
IntelliSense Engine = default.
Querying compiler for default C++ language standard using command line: /usr/bin/gcc -x c++ -E -dM /dev/null
Detected language standard version: gnu++17
Querying compiler's default target using command line: "/usr/bin/gcc" -dumpmachine
Compiler returned default target value: x86_64-linux-gnu
Code browsing service initialized
Folder: /usr/include/ will be indexed
Folder: /usr/lib/gcc/x86_64-linux-gnu/12/include/ will be indexed
Folder: /usr/local/include/ will be indexed
Folder: /home/gralpli/myproject/ will be indexed
Discovering files...
Processing folder (recursive): /usr/lib/gcc/x86_64-linux-gnu/12/include/
Processing folder (recursive): /usr/include/
Processing folder (recursive): /usr/local/include/
Processing folder (recursive): /home/gralpli/myproject/
Querying compiler for default C++ language standard using command line: /home/gralpli/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20240530/xtensa-esp-elf/bin/xtensa-esp32-elf-gcc -x c++ -E -dM /dev/null
Detected language standard version: gnu++17
Querying compiler's default target using command line: "/home/gralpli/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20240530/xtensa-esp-elf/bin/xtensa-esp32-elf-gcc" -dumpmachine
Compiler returned default target value: xtensa-esp-elf
Unhandled default compiler target value detected: xtensa-esp-elf
Failed to query compiler. Falling back to 32-bit intelliSenseMode.
Failed to query compiler. Falling back to no bitness.
Failed to query compiler. Falling back to 32-bit intelliSenseMode.
Failed to query compiler. Falling back to no bitness.
Unable to retrieve file system information for /home/gralpli/myproject/build/extension/partition_table. error = -1
Folder: /home/gralpli/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20240530/xtensa-esp-elf/lib/gcc/xtensa-esp-elf/13.2.0/include/ will be indexed
Folder: /home/gralpli/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20240530/xtensa-esp-elf/lib/gcc/xtensa-esp-elf/13.2.0/include-fixed/ will be indexed
Folder: /home/gralpli/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20240530/xtensa-esp-elf/xtensa-esp-elf/include/ will be indexed
Folder: /home/gralpli/myproject/build/ will be indexed
Folder: /home/gralpli/esp/esp-idf/components/ will be indexed
Folder: /home/gralpli/myproject/main/ will be indexed
Failed to query compiler. Falling back to 32-bit intelliSenseMode.
Discovering files: 124 file(s) processed
Done discovering files.
Discovering files...
Failed to query compiler. Falling back to no bitness.
Processing folder (recursive): /home/gralpli/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20240530/xtensa-esp-elf/lib/gcc/xtensa-esp-elf/13.2.0/include-fixed/
Processing folder (recursive): /home/gralpli/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20240530/xtensa-esp-elf/xtensa-esp-elf/include/
Processing folder (recursive): /home/gralpli/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20240530/xtensa-esp-elf/lib/gcc/xtensa-esp-elf/13.2.0/include/
Processing folder (recursive): /home/gralpli/myproject/build/
Processing folder (recursive): /home/gralpli/esp/esp-idf/components/
Processing folder (recursive): /home/gralpli/myproject/main/
Discovering files: 18951 file(s) processed
109 file(s) removed from database
Done discovering files.
Populating include completion cache.
Parsing remaining files...
Parsing: 0 files(s) processed
Done parsing remaining files.
Autocomplete is enabled.
Error squiggles are enabled if all header dependencies are resolved.
Hover is enabled.
IntelliSense Engine = default.
Enhanced Colorization is enabled.
CMake: Log Diagnostics:
{
"os": "linux",
"vscodeVersion": "1.93.1",
"cmtVersion": "1.20.6",
"configurations": [
{
"folder": "/home/gralpli/myproject",
"cmakeVersion": "3.30.3",
"configured": true,
"generator": "Ninja",
"usesPresets": false,
"compilers": {
"C": "/home/gralpli/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20240530/xtensa-esp-elf/bin/xtensa-esp32-elf-gcc",
"CXX": "/home/gralpli/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20240530/xtensa-esp-elf/bin/xtensa-esp32-elf-g++"
}
}
],
"cpptoolsIntegration": {
"isReady": true,
"hasCodeModel": true,
"activeBuildType": "Debug",
"buildTypesSeen": [
"Debug"
],
"requests": [],
"responses": [],
"partialMatches": [],
"targetCount": 130,
"executablesCount": 1,
"librariesCount": 88,
"targets": []
},
"settings": [
{
"communicationMode": "automatic",
"useCMakePresets": "auto",
"configureOnOpen": false
}
]
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the reproduction in main/main.cpp and the C/C++ Extension log, especially the compiler target query using -dumpmachine, which returns xtensa-esp-elf. Trace how that target is handled and verify the change against the Espressif setup; done means the user-defined literal operator no longer shows an error in IntelliSense.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, typescript
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100