Closed a-styuf closed 4 years ago
Hi @a-styuf . Did you mean to use __attribute__
? (Two T's).
Hi @a-styuf . Did you mean to use
__attribute__
? (Two T's).
Oh, sorry. Yeas, I already used two T's __attribute__
afterwards. But the result was the same.
Figure 2 and the text were fixed.
Hi @a-styuf . What OS is this on? Could you run the C/C++: Log Diagnostics" command, and post its output as well as your configuration (
c_cpp_properties.json`)?
The __weak keyword appears to be specific to ARM compilers. Adding support for ARM IntelliSense Modes is tracked by https://github.com/microsoft/vscode-cpptools/issues/4271
__attribute__
is a gcc/clang extension. If you are using an MSVC intelliSenseMode
(the default on Windows), that would explain why it's not recognized. You would need to use either a gcc or clang IntelliSense mode.
Hi, @Colengms. Thank you for help! My OS is Windows 10 Pro. And my c_cpp_properties.json is there:
{
"configurations": [
{
"name": "Win32",
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE",
"USE_HAL_DRIVER",
"STM32F405xx",
"__CC_ARM"
],
"windowsSdkVersion": "10.0.18362.0",
"compilerPath": "C:/Keil_v5/ARM/ARMCLANG/bin/armclang.exe",
"cppStandard": "c++17",
"intelliSenseMode": "clang-x64",
"includePath": [
"${workspaceFolder}/Inc",
"${workspaceFolder}/Drivers/STM32F4xx_HAL_Driver/Inc",
"${workspaceFolder}/Drivers/CMSIS/Include",
"${workspaceFolder}/Drivers/CMSIS/Device/ST/STM32F4xx/Include",
"${workspaceFolder}/Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc",
"${workspaceFolder}/Middlewares/ST/STM32_USB_Device_Library/Core/Inc",
"${workspaceFolder}/my_files"
],
"forcedInclude": [
"C:/Keil_v5/ARM/ARMCC/include/stdint.h"
]
}
],
"version": 4
}
And "C/C++: Log Diagnostics" result is presented below:
-------- Diagnostics - 04.03.2020, 11:28:24
Version: 0.27.0-insiders
Current Configuration:
{
"name": "Win32",
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE",
"USE_HAL_DRIVER",
"STM32F405xx",
"__CC_ARM"
],
"windowsSdkVersion": "10.0.18362.0",
"compilerPath": "C:/Keil_v5/ARM/ARMCLANG/bin/armclang.exe",
"cppStandard": "c++17",
"intelliSenseMode": "clang-arm",
"includePath": [
"${workspaceFolder}/Inc",
"${workspaceFolder}/Drivers/STM32F4xx_HAL_Driver/Inc",
"${workspaceFolder}/Drivers/CMSIS/Include",
"${workspaceFolder}/Drivers/CMSIS/Device/ST/STM32F4xx/Include",
"${workspaceFolder}/Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc",
"${workspaceFolder}/Middlewares/ST/STM32_USB_Device_Library/Core/Inc",
"${workspaceFolder}/my_files"
],
"forcedInclude": [
"C:/Keil_v5/ARM/ARMCC/include/stdint.h"
],
"compilerArgs": [],
"cStandard": "c99",
"browse": {
"path": [
"${workspaceFolder}/Inc",
"${workspaceFolder}/Drivers/STM32F4xx_HAL_Driver/Inc",
"${workspaceFolder}/Drivers/CMSIS/Include",
"${workspaceFolder}/Drivers/CMSIS/Device/ST/STM32F4xx/Include",
"${workspaceFolder}/Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc",
"${workspaceFolder}/Middlewares/ST/STM32_USB_Device_Library/Core/Inc",
"${workspaceFolder}/my_files",
"${workspaceFolder}"
],
"limitSymbolsToIncludedHeaders": false
}
}
Translation Unit Mappings:
[ D:\YandexDisk\Work\Microcontrolers\STM32\Projects\norby_lm_mk\my_files\lm_interfaces_data.c ]:
D:\YANDEXDISK\WORK\MICROCONTROLERS\STM32\PROJECTS\NORBY_LM_MK\MY_FILES\LM_INTERFACES_DATA.H
[ D:\YandexDisk\Work\Microcontrolers\STM32\Projects\norby_lm_mk\my_files\can.c ]:
D:\YANDEXDISK\WORK\MICROCONTROLERS\STM32\PROJECTS\NORBY_LM_MK\MY_FILES\CAN.C
Translation Unit Configurations:
[ D:\YandexDisk\Work\Microcontrolers\STM32\Projects\norby_lm_mk\my_files\lm_interfaces_data.c ]:
Process ID: 6400
Memory Usage: 15 MB
Compiler Path: C:\Program Files\LLVM\bin\clang.exe
Includes:
D:\YANDEXDISK\WORK\MICROCONTROLERS\STM32\PROJECTS\NORBY_LM_MK\INC
D:\YANDEXDISK\WORK\MICROCONTROLERS\STM32\PROJECTS\NORBY_LM_MK\DRIVERS\STM32F4XX_HAL_DRIVER\INC
D:\YANDEXDISK\WORK\MICROCONTROLERS\STM32\PROJECTS\NORBY_LM_MK\DRIVERS\CMSIS\INCLUDE
D:\YANDEXDISK\WORK\MICROCONTROLERS\STM32\PROJECTS\NORBY_LM_MK\DRIVERS\CMSIS\DEVICE\ST\STM32F4XX\INCLUDE
D:\YANDEXDISK\WORK\MICROCONTROLERS\STM32\PROJECTS\NORBY_LM_MK\MIDDLEWARES\ST\STM32_USB_DEVICE_LIBRARY\CLASS\CDC\INC
D:\YANDEXDISK\WORK\MICROCONTROLERS\STM32\PROJECTS\NORBY_LM_MK\MIDDLEWARES\ST\STM32_USB_DEVICE_LIBRARY\CORE\INC
D:\YANDEXDISK\WORK\MICROCONTROLERS\STM32\PROJECTS\NORBY_LM_MK\MY_FILES
C:\PROGRAM FILES\LLVM\LIB\CLANG\9.0.0\INCLUDE
C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\COMMUNITY\VC\TOOLS\MSVC\14.24.28314\INCLUDE
C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.18362.0\UCRT
C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.18362.0\SHARED
C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.18362.0\UM
C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.18362.0\WINRT
D:/YANDEXDISK/WORK/MICROCONTROLERS/STM32/PROJECTS/NORBY_LM_MK/MY_FILES
Defines:
_DEBUG
UNICODE
_UNICODE
USE_HAL_DRIVER
STM32F405xx
__CC_ARM
Forced Includes:
C:\KEIL_V5\ARM\ARMCC\INCLUDE\STDINT.H
Standard Version: c99
IntelliSense Mode: msvc-x64
[ D:\YandexDisk\Work\Microcontrolers\STM32\Projects\norby_lm_mk\my_files\can.c ]:
Process ID: 17692
Memory Usage: 14 MB
Compiler Path: C:\Program Files\LLVM\bin\clang.exe
Includes:
D:\YANDEXDISK\WORK\MICROCONTROLERS\STM32\PROJECTS\NORBY_LM_MK\INC
D:\YANDEXDISK\WORK\MICROCONTROLERS\STM32\PROJECTS\NORBY_LM_MK\DRIVERS\STM32F4XX_HAL_DRIVER\INC
D:\YANDEXDISK\WORK\MICROCONTROLERS\STM32\PROJECTS\NORBY_LM_MK\DRIVERS\CMSIS\INCLUDE
D:\YANDEXDISK\WORK\MICROCONTROLERS\STM32\PROJECTS\NORBY_LM_MK\DRIVERS\CMSIS\DEVICE\ST\STM32F4XX\INCLUDE
D:\YANDEXDISK\WORK\MICROCONTROLERS\STM32\PROJECTS\NORBY_LM_MK\MIDDLEWARES\ST\STM32_USB_DEVICE_LIBRARY\CLASS\CDC\INC
D:\YANDEXDISK\WORK\MICROCONTROLERS\STM32\PROJECTS\NORBY_LM_MK\MIDDLEWARES\ST\STM32_USB_DEVICE_LIBRARY\CORE\INC
D:\YANDEXDISK\WORK\MICROCONTROLERS\STM32\PROJECTS\NORBY_LM_MK\MY_FILES
C:\PROGRAM FILES\LLVM\LIB\CLANG\9.0.0\INCLUDE
C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\COMMUNITY\VC\TOOLS\MSVC\14.24.28314\INCLUDE
C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.18362.0\UCRT
C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.18362.0\SHARED
C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.18362.0\UM
C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.18362.0\WINRT
Defines:
_DEBUG
UNICODE
_UNICODE
USE_HAL_DRIVER
STM32F405xx
__CC_ARM
Forced Includes:
C:\KEIL_V5\ARM\ARMCC\INCLUDE\STDINT.H
Standard Version: c99
IntelliSense Mode: msvc-x64
Total Memory Usage: 29 MB
In ARM-keil help described that there's a difference between __weak
and __attribute__((weak))
, but it's possible to use both of them in arm-projects. There is a nuance in using these keywords in functions, but they are the same in variables (as I understand it).
Hi @a-styuf . Based on the diagnostics log, it looks like clang.exe and msvc-x64 IntelliSense modes are being used. It looks like we are failing to query your compiler (armclang.exe), and falling back to clang.exe found on your system. This should be addressed by #4271. In the meanwhile, I'd suggest setting the compiler path to a blank string (""
) to avoid falling back to another compiler. You will also need to add system include paths to your configuration (as they are normally found by querying the compiler).
Also, I'd suggest changing the clang-arm
to clang-x86
, as we don't yet support clang-arm
. This should get addressed by #4271
As long as clang-x86, clang-x64, or gcc-x86, or gcc-x64 intelliSense mode is used, __attribute__
should not be squiggled. But, the built in __weak keyword will not be supported until #4271 is done.
C/Cpp tools (0.26.3) are used for embedding soft tasks (stm32+cubeMX+keil).
I have error messages "expected ';'" in each case, when i using
__weak
(figure 1). I try to redefine__weak
as shown ARMtool-keil help:And I get another error "expected a type specifier" (figure 2).
When i find definition of
__weak
, keil redirects me to this definition:But VSCode can't link
__weak
and__WEAK
.I have found a similar problem but the question remains: why an error still occurs with the
__weak
prediction (figure 2)?Screenshots
Expected behavior: It'd be great if the editor could correctly understand the use of
__weak
.