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

Compiler query should handle GCC-like compilers that support C but not C++ (i.e. Microchip's XC16) #7534

Open
ReimuNotMoe opened this issue May 17, 2021 · 7 comments
Labels
Feature: Configuration An issue related to configuring the extension or IntelliSense Feature: IntelliSense Mode IntelliSense mode that emulates platform, compiler and target architecture Feature Request Language Service
Milestone

Comments

@ReimuNotMoe
Copy link

Bug type: Language Service

Describe the bug

  • OS and Version: Debian GNU/Linux 10 (buster)
  • VS Code Version: 1.56.1
  • C/C++ Extension Version: 1.3.1
  • Other extensions you installed (and if the issue persists after disabling them): CMake Tools 1.7.3
  • If using SSH remote, specify OS of remote machine: none

System include path can't be pulled from Microchip's XC16 compiler.

I have a PIC24 MCU project which uses CMake and worked well in CLion.

When I open the project in VSCode, it can be correctly built by clicking on the Build button. However, all #include <xc.h> lines are red underlined.

The compiler path is already set in CMakeLists.txt. I tried to mess with compilerPath and includePath in c_cpp_properties.json, and none of them worked.

The XC16 is a modified GCC and its usages are exactly same as GCC.

Steps to reproduce

  1. Change compilerPath in c_cpp_properties.json to /opt/microchip/xc16/v1.70/bin/xc16-gcc
  2. Nothing changed. All #include <xc.h> lines are still red underlined.
  3. Add /opt/microchip/xc16/v1.70/support/** (which contains the xc.h file) to includePath in c_cpp_properties.json
  4. Nothing changed as well. All #include <xc.h> lines are still red underlined.
  5. Run C/C++: Log Diagnostics, and there are no lines begin with /opt/microchip/xc16/v1.70/support/.

Expected behavior
There shouldn't be any red underlines in code.

Code sample and logs

  • Code sample
#include <xc.h>

int main(){
  while (1) {
    LATFbits.LATF1 = !LATFbits.LATF1; // Blink a LED
  }
}
  • CMakeLists part of setting the compiler
if (XC16_TARGET_CPU)
    message("-- FindXC16: CPU set to ${XC16_TARGET_CPU}")
    set(XC16_COMPILER_OPTIONS -mcpu=${XC16_TARGET_CPU})

    if (NOT XC16_DISABLE_DEFAULT_LINKER_SCRIPT)
        message("-- FindXC16: Using default linker script for device ${XC16_TARGET_CPU}")
        set(XC16_LINKER_OPTIONS --script=p${XC16_TARGET_CPU}.gld)
    else()
        message("-- FindXC16: Default linker script disabled")
    endif()
endif()

if (UNIX)
    if (APPLE)
        set(XC16_DEFAULT_SEARCH_PATH /Applications/microchip/xc16/)
    else()
        set(XC16_DEFAULT_SEARCH_PATH /opt/microchip/xc16/)
    endif()
endif()

if (WIN32)
    set(XC16_DEFAULT_SEARCH_PATH "D:/Microchip/xc16/")
endif()

if (NOT XC16_SEARCH_PATH)
    message("-- FindXC16: Variable XC16_SEARCH_PATH isn't defined, default to ${XC16_DEFAULT_SEARCH_PATH}")
    set(XC16_SEARCH_PATH ${XC16_DEFAULT_SEARCH_PATH})
endif()

set(CMAKE_C_LINK_FLAGS "")

file(GLOB_RECURSE XC16_C_COMPILER ${XC16_SEARCH_PATH}/xc16-gcc)
if (XC16_C_COMPILER)
    message("-- FindXC16: Found xc16-gcc at ${XC16_C_COMPILER}")
    set(CMAKE_C_COMPILER    ${XC16_C_COMPILER})
    set(CMAKE_ASM_COMPILER  ${XC16_C_COMPILER})
endif()

file(GLOB_RECURSE XC16_CXX_COMPILER ${XC16_SEARCH_PATH}/xc16-g++)
if (XC16_CXX_COMPILER)
    message("-- FindXC16: Found xc16-g++ at ${XC16_CXX_COMPILER}")
    set(CMAKE_CXX_COMPILER ${XC16_CXX_COMPILER})
else()
    message("-- FindXC16: xc16-g++ not found, C++ support disabled")
endif()

file(GLOB_RECURSE XC16_AR ${XC16_SEARCH_PATH}/xc16-ar)
if (XC16_AR)
    message("-- FindXC16: Found xc16-ar at ${XC16_AR}")
    set(CMAKE_AR ${XC16_AR})
endif()

file(GLOB_RECURSE XC16_OBJCOPY ${XC16_SEARCH_PATH}/xc16-objcopy)
if (XC16_OBJCOPY)
    message("-- FindXC16: Found xc16-objcopy at ${XC16_OBJCOPY}")
    set(CMAKE_OBJCOPY ${XC16_OBJCOPY})
endif()

file(GLOB_RECURSE XC16_OBJDUMP ${XC16_SEARCH_PATH}/xc16-objdump)
if (XC16_OBJDUMP)
    message("-- FindXC16: Found xc16-objdump at ${XC16_OBJDUMP}")
    set(CMAKE_OBJDUMP ${XC16_OBJDUMP})
endif()

file(GLOB_RECURSE XC16_BIN2HEX ${XC16_SEARCH_PATH}/xc16-bin2hex)
if (XC16_BIN2HEX)
    message("-- FindXC16: Found xc16-bin2hex at ${XC16_BIN2HEX}")
    set(CMAKE_OBJDUMP ${XC16_BIN2HEX})
endif()

add_compile_options(${XC16_COMPILER_OPTIONS} -Wcast-align -omf=elf -DXPRJ_default=default -legacy-libc -msmart-io=1 -msfr-warn=off)

add_link_options(-Wl,--defsym=__MPLAB_BUILD=1,${XC16_LINKER_OPTIONS},--stack=16,--check-sections,--data-init,--pack-data,--handles,--isr,--no-gc-sections,--fill-upper=0,--stackguard=16,--no-force-link,--smart-io,--report-mem)

  • CMake output
[variant] Loaded new set of variants
[kit] Successfully loaded 8 kits from /root/.local/share/CMakeTools/cmake-tools-kits.json
[main] Configuring folder: PICo24_SDK 
[cmake] -- FindXC16: Variable XC16_SEARCH_PATH isn't defined, default to /opt/microchip/xc16/
[cmake] -- FindXC16: Found xc16-gcc at /opt/microchip/xc16//v1.70/bin/xc16-gcc
[cmake] -- FindXC16: Found xc16-g++ at /opt/microchip/xc16//v1.70/bin/xc16-g++
[cmake] -- FindXC16: Found xc16-ar at /opt/microchip/xc16//v1.70/bin/xc16-ar
[cmake] -- FindXC16: Found xc16-objcopy at /opt/microchip/xc16//v1.70/bin/xc16-objcopy
[cmake] -- FindXC16: Found xc16-objdump at /opt/microchip/xc16//v1.70/bin/xc16-objdump
[cmake] -- FindXC16: Found xc16-bin2hex at /opt/microchip/xc16//v1.70/bin/xc16-bin2hex
[cmake] -- PICo24: Using board: PotatoPi_PICo24, CPU: 24FJ256GB206
[cmake] Configuring done
[cmake] Generating done
  • Configurations in c_cpp_properties.json
{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "/opt/microchip/xc16/v1.70/support/**",
                "${workspaceFolder}/**"
            ],
            "browse" :{
                "path": [
                    "/opt/microchip/xc16/v1.70/support/**",
                    "${workspaceFolder}/**"
                ]
            },
            "defines": [],
            "compilerPath": "/opt/microchip/xc16/v1.70/bin/xc16-gcc",
            "cStandard": "c99",
            "intelliSenseMode": "linux-gcc-x64",
            "configurationProvider": "ms-vscode.cmake-tools",
            "compileCommands": "${workspaceFolder}/build/compile_commands.json"
        }
    ],
    "version": 4
}
  • Logs from running C/C++: Log Diagnostics from the VS Code command palette
-------- Diagnostics - 5/17/2021, 7:43:23 PM
Version: 1.3.1
Current Configuration:
{
    "name": "Linux",
    "includePath": [
        "/opt/microchip/xc16/v1.70/support/**",
        "${workspaceFolder}/**"
    ],
    "browse": {
        "path": [
            "/opt/microchip/xc16/v1.70/support/**",
            "${workspaceFolder}/**"
        ],
        "limitSymbolsToIncludedHeaders": true
    },
    "defines": [],
    "compilerPath": "/opt/microchip/xc16/v1.70/bin/xc16-gcc",
    "cStandard": "c99",
    "intelliSenseMode": "linux-gcc-x64",
    "configurationProvider": "ms-vscode.cmake-tools",
    "compileCommands": "${workspaceFolder}/build/compile_commands.json",
    "compilerArgs": [],
    "intelliSenseModeIsExplicit": true,
    "cStandardIsExplicit": true,
    "cppStandardIsExplicit": true,
    "compilerPathIsExplicit": true
}
Custom browse configuration: 
{
    "browsePath": [
        "/root/Devel/PICo24_SDK/Boards/PotatoPi_PICo24",
        "/root/Devel/PICo24_SDK/Components",
        "/root/Devel/PICo24_SDK/Components/PICo24/Core",
        "/root/Devel/PICo24_SDK/Components/PICo24",
        "/root/Devel/PICo24_SDK/Components/PICo24/Peripherals/EXT_INT",
        "/root/Devel/PICo24_SDK/Components/PICo24/Peripherals/I2C",
        "/root/Devel/PICo24_SDK/Components/PICo24/Peripherals/SPI",
        "/root/Devel/PICo24_SDK/Components/PICo24/Peripherals/UART",
        "/root/Devel/PICo24_SDK/Components/PICo24/Peripherals/USB/Device",
        "/root/Devel/PICo24_SDK/Components/PICo24/Peripherals/USB/Host",
        "/root/Devel/PICo24_SDK/Components/PICo24/Peripherals/USB",
        "/root/Devel/PICo24_SDK/Components/PICo24/UnixAPI",
        "/root/Devel/PICo24_SDK"
    ],
    "standard": "gnu99",
    "compilerPath": "/opt/microchip/xc16/v1.70/bin/xc16-gcc",
    "compilerArgs": [
        "-fno-lto",
        "-fno-strict-aliasing",
        "-Wcast-align",
        "-omf=elf",
        "-DXPRJ_default=default",
        "-legacy-libc",
        "-msmart-io=1",
        "-msfr-warn=off",
        "-g",
        "-Os",
        "-std=gnu99",
        "-mcpu=\\\"24FJ256GB206\\\""
    ]
}
Custom configurations:
[ /root/Devel/PICo24_SDK/main.c ]
{
    "defines": [
        "XPRJ_default=default"
    ],
    "standard": "gnu99",
    "includePath": [
        "/root/Devel/PICo24_SDK/Boards/PotatoPi_PICo24",
        "/root/Devel/PICo24_SDK/Components"
    ],
    "compilerPath": "/opt/microchip/xc16/v1.70/bin/xc16-gcc",
    "compilerArgs": [
        "-fno-lto",
        "-fno-strict-aliasing",
        "-Wcast-align",
        "-omf=elf",
        "-DXPRJ_default=default",
        "-legacy-libc",
        "-msmart-io=1",
        "-msfr-warn=off",
        "-g",
        "-Os",
        "-std=gnu99",
        "-mcpu=\\\"24FJ256GB206\\\""
    ]
}
Translation Unit Mappings:
[ /root/Devel/PICo24_SDK/main.c ]:
    /root/Devel/PICo24_SDK/Components/PICo24/PICo24.h
Translation Unit Configurations:
[ /root/Devel/PICo24_SDK/main.c ]:
    Process ID: 4035
    Memory Usage: 20 MB
    Includes:
        /root/Devel/PICo24_SDK/Boards/PotatoPi_PICo24
        /root/Devel/PICo24_SDK/Components
        /usr/include/x86_64-linux-gnu/c++/8
        /usr/include/newlib/c++/7.3.1
        /usr/include/c++/8
        /usr/local/include
        /usr/lib/llvm-7/lib/clang/7.0.1/include
        /usr/include/x86_64-linux-gnu
        /usr/include/newlib
        /usr/include
    Defines:
        XPRJ_default=default
        XPRJ_default=default
    Standard Version: c99
    IntelliSense Mode: linux-gcc-x64
    Other Flags:
        --gcc
        --gnu_version=100000
Total Memory Usage: 20 MB
Browse Paths from compile_commands.json, from workspace folder: /root/Devel/PICo24_SDK
    /root/Devel/PICo24_SDK
    /root/Devel/PICo24_SDK/Boards/PotatoPi_PICo24
    /root/Devel/PICo24_SDK/Components
    /root/Devel/PICo24_SDK/Components/PICo24
    /root/Devel/PICo24_SDK/Components/PICo24/Core
    /root/Devel/PICo24_SDK/Components/PICo24/Peripherals/EXT_INT
    /root/Devel/PICo24_SDK/Components/PICo24/Peripherals/I2C
    /root/Devel/PICo24_SDK/Components/PICo24/Peripherals/SPI
    /root/Devel/PICo24_SDK/Components/PICo24/Peripherals/UART
    /root/Devel/PICo24_SDK/Components/PICo24/Peripherals/USB
    /root/Devel/PICo24_SDK/Components/PICo24/Peripherals/USB/Device
    /root/Devel/PICo24_SDK/Components/PICo24/Peripherals/USB/Host
    /root/Devel/PICo24_SDK/Components/PICo24/UnixAPI

------- Workspace parsing diagnostics -------
Number of files discovered (not excluded): 49455


File exclude: **/.vscode
File exclude: **/.git
File exclude: **/.svn
File exclude: **/.hg
File exclude: **/CVS
File exclude: **/.DS_Store
Search exclude: **/node_modules
Search exclude: **/bower_components
Search exclude: **/*.code-search
Populate include completion cache.
Discovering files...
  Processing folder (recursive): /usr/local/include/
  Processing folder (recursive): /usr/lib/llvm-7/lib/clang/7.0.1/include/
  Processing folder (recursive): /usr/include/
  Processing folder (recursive): /root/Devel/PICo24_SDK/
  Discovering files: 49486 file(s) processed
  0 file(s) removed from database
Done discovering files.
Parsing open files...
Parsing remaining files...
  Parsing: 0 files(s) processed
Done parsing remaining files.
Done parsing open files.
idle loop: reparsing the active document
Checking for syntax errors: file:///root/Devel/PICo24_SDK/main.c
Queueing IntelliSense update for files in translation unit of: /root/Devel/PICo24_SDK/main.c
Error squiggle count: 66
Update IntelliSense time (sec): 0.254
terminating child process: 6746
terminating child process: 6748
Checking for syntax errors: file:///root/Devel/PICo24_SDK/Components/PICo24/PICo24.h
Queueing IntelliSense update for files in translation unit of: /root/Devel/PICo24_SDK/main.c
idle loop: reparsing the active document
Checking for syntax errors: file:///root/Devel/PICo24_SDK/Components/PICo24/PICo24.h
Queueing IntelliSense update for files in translation unit of: /root/Devel/PICo24_SDK/main.c
0 include path suggestion(s) discovered.
Error squiggle count: 65
Error squiggle count: 11
terminating child process: 6753
Update IntelliSense time (sec): 0.609
0 include path suggestion(s) discovered.
  • xc16-gcc preprocessor output:
➜  build git:(master) ✗ /opt/microchip/xc16/v1.70/bin/xc16-gcc -v -E -dD empty.c
Microchip Language Tool Shell Version 1.70 (Build date: Mar  2 2021).
Copyright (c) 2012-2017 Microchip Technology Inc. All rights reserved
Using built-in specs.
COLLECT_GCC=/opt/microchip/xc16/v1.70/bin/bin/elf-gcc
Target: pic30-elf
Configured with: /home/xc16/release-builds/build_20210302/src/XC_GCC/gcc/configure --build=x86_64-linux --target=pic30-elf --disable-lto --disable-threads --disable-libmudflap --disable-libssp --disable-libstdcxx-pch --disable-hosted-libstdcxx --with-gnu-as --with-gnu-ld --enable-languages=c --disable-nls --disable-libgomp --without-headers --disable-libffi --disable-bootstrap --prefix=/bin --libexecdir=/bin --program-prefix=pic30- --with-libelf=/home/xc16/release-builds/build_20210302/bin/XC_GCC-elf-linux64-xclm/host-libs/ --with-dwarf2 --with-gmp=/home/xc16/release-builds/build_20210302/bin/XC_GCC-elf-linux64-xclm/host-libs --with-ppl=/home/xc16/release-builds/build_20210302/bin/XC_GCC-elf-linux64-xclm/host-libs --with-cloog=/home/xc16/release-builds/build_20210302/bin/XC_GCC-elf-linux64-xclm/host-libs --with-zlib=/home/xc16/release-builds/build_20210302/bin/XC_GCC-elf-linux64-xclm/host-libs --with-bugurl=https://www.microchip.com/technical-support --with-host-libstdcxx=
Thread model: single
gcc version 4.5.1 (XC16, Microchip v1.70) Build date: Mar  2 2021 (Microchip Technology) 
COLLECT_GCC_OPTIONS='-v' '-E' '-dD' '-mlegacy-libc'
 /opt/microchip/xc16/v1.70/bin/bin/../xc16-cc1 -E -quiet -v -iprefix /opt/microchip/xc16/v1.70/bin/bin/../pic30-elf/4.5.1/ empty.c -mresource=/opt/microchip/xc16/v1.70/bin/bin/../c30_device.info -omf=elf -mlegacy-libc -dD
Microchip Language Tool Shell Version 1.70 (Build date: Mar  2 2021).
Copyright (c) 2012-2017 Microchip Technology Inc. All rights reserved
ignoring nonexistent directory "/opt/microchip/xc16/v1.70/bin/bin/../pic30-elf/4.5.1/include"
ignoring nonexistent directory "/opt/microchip/xc16/v1.70/bin/bin/../pic30-elf/4.5.1/include-fixed"
ignoring nonexistent directory "/opt/microchip/xc16/v1.70/bin/bin/../pic30-elf/4.5.1/../../../../pic30-elf/sys-include"
ignoring nonexistent directory "/opt/microchip/xc16/v1.70/bin/bin/../pic30-elf/4.5.1/../../../../pic30-elf/include"
ignoring nonexistent directory "/root/Downloads/xc16_v1.70.src/v1.70.src/install-linux64/bin/lib/gcc/pic30-elf/4.5.1/include"
ignoring nonexistent directory "/root/Downloads/xc16_v1.70.src/v1.70.src/install-linux64/bin/lib/gcc/pic30-elf/4.5.1/include-fixed"
ignoring nonexistent directory "/root/Downloads/xc16_v1.70.src/v1.70.src/install-linux64/bin/pic30-elf/sys-include"
ignoring nonexistent directory "/root/Downloads/xc16_v1.70.src/v1.70.src/install-linux64/bin/pic30-elf/include"
#include "..." search starts here:
#include <...> search starts here:
 /opt/microchip/xc16/v1.70/bin/bin/../../include/lega-c
 /opt/microchip/xc16/v1.70/bin/bin/../../support/generic/h
End of search list.
# 1 "empty.c"
# 1 "<built-in>"
#define __STDC__ 1
#define __STDC_HOSTED__ 1
#define __GNUC__ 4
#define __GNUC_MINOR__ 5
#define __GNUC_PATCHLEVEL__ 1
#define __SIZE_TYPE__ unsigned int
#define __PTRDIFF_TYPE__ int
#define __WCHAR_TYPE__ short unsigned int
#define __WINT_TYPE__ unsigned int
#define __INTMAX_TYPE__ long long int
#define __UINTMAX_TYPE__ long long unsigned int
#define __CHAR16_TYPE__ short unsigned int
#define __CHAR32_TYPE__ unsigned int
#define __GXX_ABI_VERSION 1002
#define __USING_SJLJ_EXCEPTIONS__ 1
#define __SCHAR_MAX__ 127
#define __SHRT_MAX__ 32767
#define __INT_MAX__ 32767
#define __LONG_MAX__ 2147483647L
#define __LONG_LONG_MAX__ 9223372036854775807LL
#define __WCHAR_MAX__ 65535U
#define __WCHAR_MIN__ 0U
#define __WINT_MAX__ 65535U
#define __WINT_MIN__ 0U
#define __PTRDIFF_MAX__ 32767
#define __SIZE_MAX__ 65535U
#define __CHAR_BIT__ 8
#define __INTMAX_MAX__ 9223372036854775807LL
#define __INTMAX_C(c) c ## LL
#define __UINTMAX_MAX__ 18446744073709551615ULL
#define __UINTMAX_C(c) c ## ULL
#define __FLT_EVAL_METHOD__ 0
#define __DEC_EVAL_METHOD__ 2
#define __FLT_RADIX__ 2
#define __FLT_MANT_DIG__ 24
#define __FLT_DIG__ 6
#define __FLT_MIN_EXP__ (-125)
#define __FLT_MIN_10_EXP__ (-37)
#define __FLT_MAX_EXP__ 128
#define __FLT_MAX_10_EXP__ 38
#define __FLT_MAX__ 3.4028234663852886e+38F
#define __FLT_MIN__ 1.1754943508222875e-38F
#define __FLT_EPSILON__ 1.1920928955078125e-7F
#define __FLT_DENORM_MIN__ 1.4012984643248171e-45F
#define __FLT_HAS_DENORM__ 1
#define __FLT_HAS_INFINITY__ 1
#define __FLT_HAS_QUIET_NAN__ 1
#define __DBL_MANT_DIG__ 24
#define __DBL_DIG__ 6
#define __DBL_MIN_EXP__ (-125)
#define __DBL_MIN_10_EXP__ (-37)
#define __DBL_MAX_EXP__ 128
#define __DBL_MAX_10_EXP__ 38
#define __DBL_MAX__ ((double)3.4028234663852886e+38L)
#define __DBL_MIN__ ((double)1.1754943508222875e-38L)
#define __DBL_EPSILON__ ((double)1.1920928955078125e-7L)
#define __DBL_DENORM_MIN__ ((double)1.4012984643248171e-45L)
#define __DBL_HAS_DENORM__ 1
#define __DBL_HAS_INFINITY__ 1
#define __DBL_HAS_QUIET_NAN__ 1
#define __LDBL_MANT_DIG__ 53
#define __LDBL_DIG__ 15
#define __LDBL_MIN_EXP__ (-1021)
#define __LDBL_MIN_10_EXP__ (-307)
#define __LDBL_MAX_EXP__ 1024
#define __LDBL_MAX_10_EXP__ 308
#define __DECIMAL_DIG__ 17
#define __LDBL_MAX__ 1.7976931348623157e+308L
#define __LDBL_MIN__ 2.2250738585072014e-308L
#define __LDBL_EPSILON__ 2.2204460492503131e-16L
#define __LDBL_DENORM_MIN__ 4.9406564584124654e-324L
#define __LDBL_HAS_DENORM__ 1
#define __LDBL_HAS_INFINITY__ 1
#define __LDBL_HAS_QUIET_NAN__ 1
#define __DEC32_MANT_DIG__ 7
#define __DEC32_MIN_EXP__ (-94)
#define __DEC32_MAX_EXP__ 97
#define __DEC32_MIN__ 1E-95DF
#define __DEC32_MAX__ 9.999999E96DF
#define __DEC32_EPSILON__ 1E-6DF
#define __DEC32_SUBNORMAL_MIN__ 0.000001E-95DF
#define __DEC64_MANT_DIG__ 16
#define __DEC64_MIN_EXP__ (-382)
#define __DEC64_MAX_EXP__ 385
#define __DEC64_MIN__ 1E-383DD
#define __DEC64_MAX__ 9.999999999999999E384DD
#define __DEC64_EPSILON__ 1E-15DD
#define __DEC64_SUBNORMAL_MIN__ 0.000000000000001E-383DD
#define __DEC128_MANT_DIG__ 34
#define __DEC128_MIN_EXP__ (-6142)
#define __DEC128_MAX_EXP__ 6145
#define __DEC128_MIN__ 1E-6143DL
#define __DEC128_MAX__ 9.999999999999999999999999999999999E6144DL
#define __DEC128_EPSILON__ 1E-33DL
#define __DEC128_SUBNORMAL_MIN__ 0.000000000000000000000000000000001E-6143DL
#define __REGISTER_PREFIX__ 
#define __USER_LABEL_PREFIX__ _
#define __VERSION__ "4.5.1 (XC16, Microchip v0_00) Build date: May  5 2021"
#define __GNUC_GNU_INLINE__ 1
#define __NO_INLINE__ 1
#define __FINITE_MATH_ONLY__ 0
#define __PRAGMA_REDEFINE_EXTNAME 1
#define __SIZEOF_INT__ 2
#define __SIZEOF_LONG__ 4
#define __SIZEOF_LONG_LONG__ 8
#define __SIZEOF_SHORT__ 2
#define __SIZEOF_FLOAT__ 4
#define __SIZEOF_DOUBLE__ 4
#define __SIZEOF_LONG_DOUBLE__ 8
#define __SIZEOF_SIZE_T__ 2
#define __SIZEOF_WCHAR_T__ 2
#define __SIZEOF_WINT_T__ 2
#define __SIZEOF_PTRDIFF_T__ 2
#define __SIZEOF_POINTER__ 2
#define __OPTIMIZATION_LEVEL__ 0
#define __LARGE_ARRAYS__ 0
#define __BUILTIN_ITTYPE 1
#define __C30_VERSION__ 0
#define __XC16_VERSION 0
#define __XC16_VERSION__ 0
#define __XC__ 1
#define __XC16 1
#define __C30 1
#define __dsPIC30 1
#define __C30__ 1
#define __XC16__ 1
#define __dsPIC30__ 1
#define __XC16ELF 1
#define __C30ELF 1
#define __dsPIC30ELF 1
#define __C30ELF__ 1
#define __XC16ELF__ 1
#define __dsPIC30ELF__ 1
#define C30 1
#define XC16 1
#define dsPIC30 1
#define __HAS_DSP__ 1
#define __BIGGEST_ALIGNMENT__ 2
# 1 "<command-line>"
# 1 "empty.c"
PIC30_COMPILER_PATH=/opt/microchip/xc16/v1.70/bin/bin/../
PIC30_LIBRARY_PATH=/opt/microchip/xc16/v1.70/bin/bin/../:/opt/microchip/xc16/v1.70/bin/bin/../../lib/:/opt/microchip/xc16/v1.70/bin/bin/../../lib/PIC24E/:/opt/microchip/xc16/v1.70/bin/bin/../../support/PIC24E/gld/:/opt/microchip/xc16/v1.70/bin/bin/../../lib/PIC24F/:/opt/microchip/xc16/v1.70/bin/bin/../../support/PIC24F/gld/:/opt/microchip/xc16/v1.70/bin/bin/../../lib/PIC24H/:/opt/microchip/xc16/v1.70/bin/bin/../../support/PIC24H/gld/:/opt/microchip/xc16/v1.70/bin/bin/../../lib/dsPIC30F/:/opt/microchip/xc16/v1.70/bin/bin/../../support/dsPIC30F/gld/:/opt/microchip/xc16/v1.70/bin/bin/../../support/dsPIC33C/gld/:/opt/microchip/xc16/v1.70/bin/bin/../../lib/dsPIC33E/:/opt/microchip/xc16/v1.70/bin/bin/../../support/dsPIC33E/gld/:/opt/microchip/xc16/v1.70/bin/bin/../../lib/dsPIC33F/:/opt/microchip/xc16/v1.70/bin/bin/../../support/dsPIC33F/gld/
COLLECT_GCC_OPTIONS='-v' '-E' '-dD' '-mlegacy-libc'

Screenshots

Screenshot_20210517_202459

@sean-mcmanus sean-mcmanus self-assigned this May 17, 2021
@sean-mcmanus
Copy link
Collaborator

With C_Cpp.loggingLevel set to "Debug" can you look in the "C/C++" logging for a failure message after "Compiler query command line: "? I don't see that in your existing logging.

@sean-mcmanus sean-mcmanus added the more info needed The issue report is not actionable in its current state label May 17, 2021
@ReimuNotMoe
Copy link
Author

With C_Cpp.loggingLevel set to "Debug" can you look in the "C/C++" logging for a failure message after "Compiler query command line: "? I don't see that in your existing logging.

The logs are extremely long, so I didn't include all of them.

Here they are:

Attempting to get defaults from C compiler in "compilerPath" property: '/opt/microchip/xc16/v1.70/bin/xc16-gcc'
Querying compiler for default C++ language standard using command line: "/opt/microchip/xc16/v1.70/bin/xc16-gcc" -x c++ -E -dM /dev/null
terminating child process: 55881
Querying compiler for default C language standard using command line: "/opt/microchip/xc16/v1.70/bin/xc16-gcc" -x c -E -dM /dev/null
terminating child process: 55885
Querying compiler's default target using command line: "/opt/microchip/xc16/v1.70/bin/xc16-gcc" -dumpmachine
Compiler returned default target value: pic30-elf

terminating child process: 55891
Unhandled default compiler target value detected: pic30-elf

Compiler query command line: "/opt/microchip/xc16/v1.70/bin/xc16-gcc" -std=c99 -Wp,-v -E -dD -x c -m64  /dev/null
Compiler does not support 64-bit. Falling back to 32-bit intelliSenseMode.
terminating child process: 55895
Compiler query command line: "/opt/microchip/xc16/v1.70/bin/xc16-gcc" -std=c99 -Wp,-v -E -dD -x c -m32  /dev/null
Failed to query compiler. Falling back to no bitness.
terminating child process: 55901
Compiler query command line: "/opt/microchip/xc16/v1.70/bin/xc16-gcc" -std=c99 -Wp,-v -E -dD -x c   /dev/null
terminating child process: 55907
Shutting down IntelliSense server: /root/Devel/PICo24_SDK/main.c
  Folder: /usr/local/include/ will be indexed
  Folder: /usr/lib/llvm-7/lib/clang/7.0.1/include/ will be indexed
  Folder: /usr/include/ will be indexed
  Folder: /root/Devel/PICo24_SDK/ will be indexed
Attempting to get defaults from C++ compiler in "compilerPath" property: '/opt/microchip/xc16/v1.70/bin/xc16-gcc'
Compiler query command line: "/opt/microchip/xc16/v1.70/bin/xc16-gcc" -std=c++17 -Wp,-v -E -dD -x c++ -m64  /dev/null
terminating child process: 55913
Compiler query command line: "/opt/microchip/xc16/v1.70/bin/xc16-gcc" -std=c++1z -Wp,-v -E -dD -x c++ -m64  /dev/null
terminating child process: 55916
Compiler query command line: "/opt/microchip/xc16/v1.70/bin/xc16-gcc" -std=c++14 -Wp,-v -E -dD -x c++ -m64  /dev/null
terminating child process: 55919
Compiler query command line: "/opt/microchip/xc16/v1.70/bin/xc16-gcc" -std=c++1y -Wp,-v -E -dD -x c++ -m64  /dev/null
terminating child process: 55922
Compiler query command line: "/opt/microchip/xc16/v1.70/bin/xc16-gcc" -std=c++11 -Wp,-v -E -dD -x c++ -m64  /dev/null
terminating child process: 55925
Compiler query command line: "/opt/microchip/xc16/v1.70/bin/xc16-gcc" -std=c++0x -Wp,-v -E -dD -x c++ -m64  /dev/null
terminating child process: 55928
Compiler query command line: "/opt/microchip/xc16/v1.70/bin/xc16-gcc" -std=c++03 -Wp,-v -E -dD -x c++ -m64  /dev/null
terminating child process: 55931
Compiler query command line: "/opt/microchip/xc16/v1.70/bin/xc16-gcc" -std=c++98 -Wp,-v -E -dD -x c++ -m64  /dev/null
terminating child process: 55934
Compiler query command line: "/opt/microchip/xc16/v1.70/bin/xc16-gcc" -std=gnu++20 -Wp,-v -E -dD -x c++ -m64  /dev/null
terminating child process: 55937
Compiler query command line: "/opt/microchip/xc16/v1.70/bin/xc16-gcc" -std=gnu++2a -Wp,-v -E -dD -x c++ -m64  /dev/null
terminating child process: 55940
Compiler query command line: "/opt/microchip/xc16/v1.70/bin/xc16-gcc" -std=gnu++17 -Wp,-v -E -dD -x c++ -m64  /dev/null
terminating child process: 55943
Compiler query command line: "/opt/microchip/xc16/v1.70/bin/xc16-gcc" -std=gnu++1z -Wp,-v -E -dD -x c++ -m64  /dev/null
terminating child process: 55946
Compiler query command line: "/opt/microchip/xc16/v1.70/bin/xc16-gcc" -std=gnu++14 -Wp,-v -E -dD -x c++ -m64  /dev/null
terminating child process: 55949
Compiler query command line: "/opt/microchip/xc16/v1.70/bin/xc16-gcc" -std=gnu++1y -Wp,-v -E -dD -x c++ -m64  /dev/null
terminating child process: 55952
Compiler query command line: "/opt/microchip/xc16/v1.70/bin/xc16-gcc" -std=gnu++11 -Wp,-v -E -dD -x c++ -m64  /dev/null
terminating child process: 55955
Compiler query command line: "/opt/microchip/xc16/v1.70/bin/xc16-gcc" -std=gnu++0x -Wp,-v -E -dD -x c++ -m64  /dev/null
terminating child process: 55958
Compiler query command line: "/opt/microchip/xc16/v1.70/bin/xc16-gcc" -std=gnu++03 -Wp,-v -E -dD -x c++ -m64  /dev/null
terminating child process: 55961
Compiler query command line: "/opt/microchip/xc16/v1.70/bin/xc16-gcc" -std=gnu++98 -Wp,-v -E -dD -x c++ -m64  /dev/null
terminating child process: 55964
Compiler query command line: "/opt/microchip/xc16/v1.70/bin/xc16-gcc"  -Wp,-v -E -dD -x c++ -m64  /dev/null
Failed to query default include paths and defines for /opt/microchip/xc16/v1.70/bin/xc16-gcc.
terminating child process: 55967

Screenshot_20210518_140142

@Colengms Colengms assigned Colengms and unassigned sean-mcmanus May 19, 2021
@Colengms Colengms added Language Service investigate: repro This issue's repro steps needs to be investigated/confirmed and removed more info needed The issue report is not actionable in its current state labels May 19, 2021
@Colengms
Copy link
Collaborator

Curious. It looks like the compiler query is insisting on adding -m64 and not falling back to -m32 or 'no bitness' for some reason, when querying as a C++ compiler. Querying as a C compiler works fine.

Does the XC16 compiler support only C, and not C++? At this link, I noticed the following: C++ only available in MPLAB XC32++ compilers

It would seem likely that this issue is lack of support for querying gcc-like C compilers that do not support C++. @ReimuNotMoe Could you confirm that the compiler you are using does not support C++?

@Colengms Colengms added more info needed The issue report is not actionable in its current state and removed investigate: repro This issue's repro steps needs to be investigated/confirmed labels May 19, 2021
@ReimuNotMoe
Copy link
Author

Curious. It looks like the compiler query is insisting on adding -m64 and not falling back to -m32 or 'no bitness' for some reason, when querying as a C++ compiler. Querying as a C compiler works fine.

Does the XC16 compiler support only C, and not C++? At this link, I noticed the following: C++ only available in MPLAB XC32++ compilers

It would seem likely that this issue is lack of support for querying gcc-like C compilers that do not support C++. @ReimuNotMoe Could you confirm that the compiler you are using does not support C++?

Yes. Only C is officially supported by XC16, however there are unofficial community support for C++98 (by modifying the XC16 build script).

There are many other compilers that follows GCC's usages and only supports C, such as some 8051 MCU compilers.

I think you can simply check if CMAKE_CXX_COMPILER is set in CMakeLists.txt or if compilers.CXX is set for a particular kit defined in cmake-tools-kits.json.

@Colengms Colengms changed the title System include path can't be pulled from Microchip's XC16 compiler Compiler query should handle GCC-like compilers that support C but not C++ (i.e. Microchip's XC16) May 20, 2021
@Colengms Colengms removed the more info needed The issue report is not actionable in its current state label May 20, 2021
@Colengms
Copy link
Collaborator

Colengms commented May 20, 2021

Addressing this would seem to require deciding how to handle C++ files if opened. Perhaps it should fall back to auto-detected defaults (a C++ compiler found on the system), though that would require tracking 2 active configurations where currently only 1 is tracked. Or, perhaps it should simply disable IntelliSense for C++ files, and/or display a warning.

@sean-mcmanus
Copy link
Collaborator

We could also potentially add cppCompilerPath/Args and cCompilerPath/Args settings (there are other scenarios were having 2 settings would be useful when using both C and C++ with compilerArgs that are only valid with one of the languages).

@Colengms Colengms added this to the Backlog milestone Jun 8, 2021
@Colengms Colengms added Feature Request Feature: Configuration An issue related to configuring the extension or IntelliSense labels Jun 8, 2021
@DanieleNardi
Copy link

I had a similar issue, solved adding the following lines to the "compilerArgs" entry in c_cpp_properties.json:

-include path-to-device-header-file.h
-mdfp=path-to-device-pack

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature: Configuration An issue related to configuring the extension or IntelliSense Feature: IntelliSense Mode IntelliSense mode that emulates platform, compiler and target architecture Feature Request Language Service
Projects
None yet
Development

No branches or pull requests

5 participants