mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
fix(linux): define __assert_func for IDF_TARGET=linux on macOS
This commit is contained in:
parent
b56bb7d8e4
commit
c90b6c18c9
@ -4,7 +4,7 @@ if(NOT "${target}" STREQUAL "linux")
|
||||
endif()
|
||||
|
||||
if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin")
|
||||
list(APPEND srcs getrandom.c)
|
||||
list(APPEND srcs getrandom.c assert_func.c)
|
||||
endif()
|
||||
|
||||
idf_component_register(INCLUDE_DIRS include
|
||||
|
23
components/linux/assert_func.c
Normal file
23
components/linux/assert_func.c
Normal file
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "hal/assert.h"
|
||||
|
||||
// Implementation of __assert_func for macOS.
|
||||
void __assert_func(const char *file, int line, const char *func, const char *expr)
|
||||
{
|
||||
fprintf(stderr, "assert failed at %s:%d (%s): %s\n", file, line, func, expr);
|
||||
abort();
|
||||
}
|
||||
|
||||
// Defining this symbol as well, since `hal` component will add "-U __assert_func" linker option,
|
||||
// and symbols are prefixed with an additional underscore on macOS.
|
||||
// (Can't use __attribute__((alias)) because aliases are not supported on macOS.)
|
||||
void _assert_func(const char *file, int line, const char *func, const char *expr)
|
||||
{
|
||||
__assert_func(file, line, func, expr);
|
||||
}
|
Loading…
Reference in New Issue
Block a user