update error_handling project CMake file
This commit is contained in:
44
Chapter07/error_handling/.vscode/settings.json
vendored
44
Chapter07/error_handling/.vscode/settings.json
vendored
@@ -2,7 +2,49 @@
|
|||||||
"files.associations": {
|
"files.associations": {
|
||||||
"span": "cpp",
|
"span": "cpp",
|
||||||
"array": "cpp",
|
"array": "cpp",
|
||||||
"string_view": "cpp"
|
"string_view": "cpp",
|
||||||
|
"exception": "cpp",
|
||||||
|
"atomic": "cpp",
|
||||||
|
"bit": "cpp",
|
||||||
|
"*.tcc": "cpp",
|
||||||
|
"cctype": "cpp",
|
||||||
|
"clocale": "cpp",
|
||||||
|
"cmath": "cpp",
|
||||||
|
"compare": "cpp",
|
||||||
|
"concepts": "cpp",
|
||||||
|
"cstdarg": "cpp",
|
||||||
|
"cstddef": "cpp",
|
||||||
|
"cstdint": "cpp",
|
||||||
|
"cstdio": "cpp",
|
||||||
|
"cstdlib": "cpp",
|
||||||
|
"cwchar": "cpp",
|
||||||
|
"cwctype": "cpp",
|
||||||
|
"deque": "cpp",
|
||||||
|
"string": "cpp",
|
||||||
|
"unordered_map": "cpp",
|
||||||
|
"vector": "cpp",
|
||||||
|
"algorithm": "cpp",
|
||||||
|
"functional": "cpp",
|
||||||
|
"iterator": "cpp",
|
||||||
|
"memory": "cpp",
|
||||||
|
"memory_resource": "cpp",
|
||||||
|
"numeric": "cpp",
|
||||||
|
"optional": "cpp",
|
||||||
|
"random": "cpp",
|
||||||
|
"system_error": "cpp",
|
||||||
|
"tuple": "cpp",
|
||||||
|
"type_traits": "cpp",
|
||||||
|
"utility": "cpp",
|
||||||
|
"initializer_list": "cpp",
|
||||||
|
"iosfwd": "cpp",
|
||||||
|
"limits": "cpp",
|
||||||
|
"new": "cpp",
|
||||||
|
"numbers": "cpp",
|
||||||
|
"ostream": "cpp",
|
||||||
|
"stdexcept": "cpp",
|
||||||
|
"streambuf": "cpp",
|
||||||
|
"cinttypes": "cpp",
|
||||||
|
"typeinfo": "cpp"
|
||||||
},
|
},
|
||||||
"C_Cpp.errorSquiggles": "disabled"
|
"C_Cpp.errorSquiggles": "disabled"
|
||||||
}
|
}
|
||||||
@@ -9,7 +9,23 @@ set(CMAKE_OBJCOPY "arm-none-eabi-objcopy")
|
|||||||
set(CMAKE_SIZE "arm-none-eabi-size")
|
set(CMAKE_SIZE "arm-none-eabi-size")
|
||||||
|
|
||||||
set(RENODE "renode" CACHE STRING "Path to Renode executable")
|
set(RENODE "renode" CACHE STRING "Path to Renode executable")
|
||||||
message(STATUS "Using Renode at: ${RENODE}")
|
|
||||||
|
set(MAIN_CPP_PATH "${CMAKE_SOURCE_DIR}/app/src/")
|
||||||
|
set(MAIN_CPP_FILE_NAME "main_assert.cpp" CACHE STRING "main file")
|
||||||
|
list(APPEND LIB_SPECS "-specs=nosys.specs")
|
||||||
|
|
||||||
|
set(EXCEPTIONS_FLAGS "-fno-exceptions -fno-rtti")
|
||||||
|
|
||||||
|
if("${MAIN_CPP_FILE_NAME}" STREQUAL "main_exceptions.cpp")
|
||||||
|
message(STATUS "Enabling exceptions")
|
||||||
|
set(EXCEPTIONS_FLAGS "-fexceptions")
|
||||||
|
set(LIB_SPECS "-specs=nosys.specs")
|
||||||
|
else()
|
||||||
|
message(STATUS "Exceptions are disabled")
|
||||||
|
list(APPEND LIB_SPECS "-specs=nano.specs")
|
||||||
|
endif()
|
||||||
|
message(STATUS "Exceptions flags set to: ${EXCEPTIONS_FLAGS}")
|
||||||
|
message(STATUS "Lib specs set to: ${LIB_SPECS}")
|
||||||
|
|
||||||
|
|
||||||
find_program(CCACHE_FOUND ccache)
|
find_program(CCACHE_FOUND ccache)
|
||||||
@@ -23,11 +39,11 @@ set(CDEFS "-DUSE_HAL_DRIVER -DSTM32F072xB")
|
|||||||
set(MCU "-mcpu=cortex-m0 -mthumb")
|
set(MCU "-mcpu=cortex-m0 -mthumb")
|
||||||
set(COMMON_FLAGS "${MCU} ${CDEFS} -fdata-sections -ffunction-sections -Wno-address-of-packed-member -Wall -Wextra -Wno-unused-parameter")
|
set(COMMON_FLAGS "${MCU} ${CDEFS} -fdata-sections -ffunction-sections -Wno-address-of-packed-member -Wall -Wextra -Wno-unused-parameter")
|
||||||
set(CMAKE_C_FLAGS "${COMMON_FLAGS}")
|
set(CMAKE_C_FLAGS "${COMMON_FLAGS}")
|
||||||
set(CMAKE_CXX_FLAGS "${COMMON_FLAGS} -Wno-register -fno-exceptions -fno-rtti -fno-threadsafe-statics")
|
set(CMAKE_CXX_FLAGS "${COMMON_FLAGS} -Wno-register ${EXCEPTIONS_FLAGS} -fno-threadsafe-statics")
|
||||||
set(CMAKE_ASM_FLAGS "${COMMON_FLAGS} -x assembler-with-cpp")
|
set(CMAKE_ASM_FLAGS "${COMMON_FLAGS} -x assembler-with-cpp")
|
||||||
|
|
||||||
set(CMAKE_C_FLAGS_DEBUG "-g -gdwarf-2 -O1")
|
set(CMAKE_C_FLAGS_DEBUG "-g -gdwarf-2 -O0")
|
||||||
set(CMAKE_CXX_FLAGS_DEBUG "-g -gdwarf-2 -O1")
|
set(CMAKE_CXX_FLAGS_DEBUG "-g -gdwarf-2 -O0")
|
||||||
set(CMAKE_C_FLAGS_RELEASE "-O2 -flto")
|
set(CMAKE_C_FLAGS_RELEASE "-O2 -flto")
|
||||||
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -flto")
|
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -flto")
|
||||||
set(CMAKE_C_FLAGS_MINSIZEREL "-Os -flto")
|
set(CMAKE_C_FLAGS_MINSIZEREL "-Os -flto")
|
||||||
@@ -83,9 +99,6 @@ include_directories(
|
|||||||
${CMAKE_SOURCE_DIR}/cstdlib_support
|
${CMAKE_SOURCE_DIR}/cstdlib_support
|
||||||
)
|
)
|
||||||
|
|
||||||
set(MAIN_CPP_PATH "${CMAKE_SOURCE_DIR}/app/src/")
|
|
||||||
set(MAIN_CPP_FILE_NAME "main_assert.cpp" CACHE STRING "main")
|
|
||||||
|
|
||||||
set(EXECUTABLE ${PROJECT_NAME}.elf)
|
set(EXECUTABLE ${PROJECT_NAME}.elf)
|
||||||
|
|
||||||
add_executable(
|
add_executable(
|
||||||
@@ -118,8 +131,7 @@ target_link_options(
|
|||||||
-T${CMAKE_SOURCE_DIR}/platform/STM32F072C8Tx_FLASH.ld
|
-T${CMAKE_SOURCE_DIR}/platform/STM32F072C8Tx_FLASH.ld
|
||||||
-mcpu=cortex-m0
|
-mcpu=cortex-m0
|
||||||
-mthumb
|
-mthumb
|
||||||
-specs=nano.specs
|
${LIB_SPECS}
|
||||||
-specs=nosys.specs
|
|
||||||
-lnosys
|
-lnosys
|
||||||
-u
|
-u
|
||||||
-lc
|
-lc
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
#include <csignal>
|
||||||
#include <exception>
|
#include <exception>
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
#include <stm32f072xb.h>
|
#include <stm32f072xb.h>
|
||||||
|
|
||||||
@@ -39,11 +41,27 @@ int main()
|
|||||||
|
|
||||||
std::array<int, 4> arr;
|
std::array<int, 4> arr;
|
||||||
|
|
||||||
arr.at(5) = 6;
|
//arr.at(5) = 6;
|
||||||
|
|
||||||
printf("Exceptions example\r\n");
|
//throw 1;
|
||||||
|
try {
|
||||||
|
//throw 1;
|
||||||
|
arr.at(5) = 6;
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (int i) {
|
||||||
|
printf("i = %d\r\n", i);
|
||||||
|
}
|
||||||
|
catch(std::out_of_range) {
|
||||||
|
printf("out of range\r\n");
|
||||||
|
}
|
||||||
|
catch (...) {
|
||||||
|
printf("Catch\r\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
while(true)
|
while(true)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user