-
-
Notifications
You must be signed in to change notification settings - Fork 132
Closed
Labels
Description
We can build this library without the -no-exceptions flag and then link it with a no-exceptions library. However, I found that without exception support, the stack will be empty. Here is an simple example.
cmake_minimum_required(VERSION 3.24...3.26)
project(test)
set(CMAKE_CXX_STANDARD 20)
include(FetchContent)
FetchContent_Declare(
cpptrace
GIT_REPOSITORY https://github.com/jeremy-rifkin/cpptrace.git
GIT_TAG v0.7.0 # <HASH or TAG>
)
FetchContent_MakeAvailable(cpptrace)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions")
add_executable(my_target test.cc)
target_link_libraries(my_target cpptrace::cpptrace)
# Create a .dSYM file on macOS
if(APPLE)
add_custom_command(
TARGET my_target
POST_BUILD
COMMAND dsymutil $<TARGET_FILE:my_target>
)
endif()
#include "cpptrace/cpptrace.hpp"
void test() {
cpptrace::generate_trace().print();
}
int main() {
test();
}
/*
Stack trace (most recent call first):
<empty trace>
*/
I test it on Apple M2 Pro macbook.