idf.py build ignores defines in c_cpp_settings.json
Posted: Sat Sep 10, 2022 3:32 pm
Hello
I have a problem with compiling my project. I've created some debug configuration for my project in c_cpp_settings.json and there is a "__DEBUG" item in sections defines. But when I try to check it in my main.cpp file I see that no __DEBUG directive has been added (#else branch works):
extern "C" void app_main(void)
{
#ifdef __DEBUG
Target = TargetBase::CreateInstance(DEVICE_TYPE);
#else
Target = TargetBase::CreateInstance();
#endif
// Some code below
}
My c_cpp_settings.json:
{
"configurations": [
{
"name": "Debug",
"compilerPath": "C:\\esp\\tools\\xtensa-esp32-elf\\esp-2022r1-RC1-11.2.0\\xtensa-esp32-elf\\bin\\xtensa-esp32-elf-gcc.exe",
"cStandard": "c11",
"cppStandard": "c++17",
"compileCommands": "${workspaceFolder}/build/compile_commands.json",
"includePath": [
"${config:idf.espIdfPathWin}/components/**",
"${workspaceFolder}/**"
],
"defines": [
"__DEBUG"
],
"browse": {
"path": [
"${config:idf.espIdfPathWin}/components",
"${workspaceFolder}"
],
"limitSymbolsToIncludedHeaders": false
},
"intelliSenseMode": "linux-gcc-x86",
"compilerArgs": []
},
],
"version": 4
}
What can I do for solving this problem?
I have a problem with compiling my project. I've created some debug configuration for my project in c_cpp_settings.json and there is a "__DEBUG" item in sections defines. But when I try to check it in my main.cpp file I see that no __DEBUG directive has been added (#else branch works):
extern "C" void app_main(void)
{
#ifdef __DEBUG
Target = TargetBase::CreateInstance(DEVICE_TYPE);
#else
Target = TargetBase::CreateInstance();
#endif
// Some code below
}
My c_cpp_settings.json:
{
"configurations": [
{
"name": "Debug",
"compilerPath": "C:\\esp\\tools\\xtensa-esp32-elf\\esp-2022r1-RC1-11.2.0\\xtensa-esp32-elf\\bin\\xtensa-esp32-elf-gcc.exe",
"cStandard": "c11",
"cppStandard": "c++17",
"compileCommands": "${workspaceFolder}/build/compile_commands.json",
"includePath": [
"${config:idf.espIdfPathWin}/components/**",
"${workspaceFolder}/**"
],
"defines": [
"__DEBUG"
],
"browse": {
"path": [
"${config:idf.espIdfPathWin}/components",
"${workspaceFolder}"
],
"limitSymbolsToIncludedHeaders": false
},
"intelliSenseMode": "linux-gcc-x86",
"compilerArgs": []
},
],
"version": 4
}
What can I do for solving this problem?