libtracefs: Remove include sys/stat.h from global tracefs.h
PATCH 1/1 libtracefs: Remove include sys/stat.h from global tracefs.h
From: "Steven Rostedt (VMware)" <[email protected]>
When using libtracefs in a program, Adding the following:
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <tracefs.h>
Caused the following error:
In file included from /usr/include/bits/statx.h:31,
from /usr/include/sys/stat.h:446,
from /usr/local/include/tracefs/tracefs.h:9,
/usr/include/linux/stat.h:57:2: error: unknown type name â__s64â
57 | __s64 tv_sec;
| ^~~~~The #define _GNU_SOURCE appears to cause this, but I needed it for my program. I tried several combinations to fix it, but the only solution I found that worked was to remove <sys/stat.h> from tracefs.h.
There's no reason to have it in the global header. The only includes that a header should have are those that the header itself needed. As tracefs.h does not need sys/stat.h itself, it should be removed.
--- include/tracefs.h | 1 - src/tracefs-tools.c | 1 + 2 files changed, 1 insertion(+), 1 deletion(-)
include/tracefs.h +0 -1
@@ -6,7 +6,6 @@#ifndef _TRACE_FS_H#define _TRACE_FS_H -#include <sys/stat.h> #include <fcntl.h> #include <sched.h> #include <event-parse.h>
src/tracefs-tools.c +1 -0
@@ -11,6 +11,7 @@#include <unistd.h> #include <fcntl.h> #include <sys/types.h> +#include <sys/stat.h> #include <regex.h> #include <dirent.h> #include <limits.h>
Signature · 1 line
2.31.1