[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: if vs. ifdef in Makefile.am
From: |
ljh |
Subject: |
Re: if vs. ifdef in Makefile.am |
Date: |
Fri, 3 Mar 2023 04:19:25 +0800 |
Hi,
I observed that it adds `NDEBUG` in `config.h`. I will need to include this
`config.h`, right?
// config.h
#define NDEBUG 1
My current solution is like the following. I do not know if it can be
simplified.
# src/configure.ac
AC_ARG_ENABLE(
[ndebug],
[AS_HELP_STRING([--enable-ndebug],
[ndebug means release and turns off assert])],
[enable_ndebug=yes]
)
AM_CONDITIONAL([NDEBUG], [test x$enable_ndebug = xyes])
---
# src/main/Makefile.am
if NDEBUG
CPPFLAGS += -DNDEBUG
CFLAGS += -O3 # .cpp
else
CFLAGS += -g # .cpp
LDFLAGS += -fsanitize=address
endif
---
// src/main/main.c
void handlerCont(int signum){
printf("SIGCONT %d\n", signum);
#ifndef NDEBUG
__lsan_do_recoverable_leak_check();
#endif
}