From 94431d4539fa391a0b9ab7cfdcca4221c7010316 Mon Sep 17 00:00:00 2001 From: Mazet Laurent Date: Wed, 9 Apr 2025 00:58:35 +0200 Subject: [PATCH] add a compilation flag to remove file location on verbose messages --- makefile | 1 + verbose.h | 25 +++++++++++++++---------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/makefile b/makefile index b9784bf..0233737 100644 --- a/makefile +++ b/makefile @@ -4,6 +4,7 @@ CC = gcc #INCLUDES = -I../debug -D__MEMORY_ALLOCATION__ INCLUDES += -DVERBOSE_COLOR=1 +#INCLUDES += -DVERBOSE_LOCATION=1 OFLAGS = -O4 -Os #OFLAGS = -O0 #OFLAGS = -O4 -ffast-math -finline-functions diff --git a/verbose.h b/verbose.h index 3eddc94..09daadf 100644 --- a/verbose.h +++ b/verbose.h @@ -23,6 +23,9 @@ __BEGIN_DECLS #ifndef VERBOSE_COLOR #define VERBOSE_COLOR 0 #endif +#ifndef VERBOSE_LOCATION +#define VERBOSE_LOCATION 0 +#endif /** Debug level @@ -99,11 +102,12 @@ __BEGIN_DECLS @param format format string @param ... optionnal arguments */ -#define PRINTF(format...) \ - do { \ - printf ("%s+%d[%s]: ", __FILE__, __LINE__, _level); \ - printf (format); \ - fflush (stdout); \ +#define PRINTF(format...) \ + do { \ + if (VERBOSE_LOCATION) printf ("%s+%d ", __FILE__, __LINE__); \ + printf ("[%s] ", _level); \ + printf (format); \ + fflush (stdout); \ } while (0) @@ -114,11 +118,12 @@ __BEGIN_DECLS @param format format string @param ... optionnal arguments */ -#define FPRINTF(stream, format...) \ - do { \ - fprintf (stream,"%s+%d[%s]: ", __FILE__, __LINE__, _level); \ - fprintf (stream, format); \ - fflush (stream); \ +#define FPRINTF(stream, format...) \ + do { \ + if (VERBOSE_LOCATION) fprintf (stream, "%s+%d ", __FILE__, __LINE__); \ + fprintf (stream, "[%s] ", _level); \ + fprintf (stream, format); \ + fflush (stream); \ } while (0) __END_DECLS -- 2.30.2