util: add guards for the etrace/trace defines

This file is really useful on its own for other projects if
auto-included via export CFLAGS="$CFLAGS -include /path/to/file.h"
However, that causes compiler warnings, let's add indef checks for this
as a quick workaround.

Since these three come as a set and are only used for debugging, we can
ifndef them all in one go rather than individually.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1423>
This commit is contained in:
Peter Hutterer 2026-02-04 11:11:01 +10:00
parent ad89a83ae6
commit e78f4f689d

View file

@ -60,15 +60,16 @@
#define DEFAULT_MOUSE_DPI 1000
#define DEFAULT_TRACKPOINT_SENSITIVITY 128
#if !defined(_trace) && !defined(trace) && !defined(etrace)
#define _trace(file, ...) \
do { \
char buf_[1024]; \
snprintf(buf_, sizeof(buf_), __VA_ARGS__); \
fprintf(file, ANSI_BLUE "%30s():%4d - " ANSI_RED "%s" ANSI_NORMAL "\n", __func__, __LINE__, buf_); \
} while (0)
#define trace(...) _trace(stdout, __VA_ARGS__)
#define etrace(...) _trace(stderr, __VA_ARGS__)
#endif
#define LIBINPUT_EXPORT __attribute__ ((visibility("default")))