As a result of the issue referenced below, we'll trade
our homegrown offset generator for an 'offsetof' macro
found in the stddef.h header file. This pleases clang.
[ and thanks to Daniel Kolesa for the report and fix ]
Reference(s):
. bug report & recommended solution
https://gitlab.com/procps-ng/procps/-/issues/235
. clang error message
proc/readproc.c:673:9: error: initializer element is not a compile-time constant
mkENT(Rss),
^~~~~~~~~~
proc/readproc.c:661:34: note: expanded from macro 'mkENT'
#define mkENT(F) { #F ":", -1, (int)((void*)&q->smap_ ## F - (void*)&q->fZERO) }
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Signed-off-by: Jim Warner <james.warner@comcast.net>
* ps: threads again display when -L is used with -q issue #234
* ps: proper aix format string behavior was restored
* sysctl: print dotted keys again
+ * top: fix 'smaps' bug preventing build under clang issue #235
procps-ng-4.0.0
---------------
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
// 1st proc_t data field
#define fZERO tid
// a smaptab entry generator
- #define mkENT(F) { #F ":", -1, (int)((void*)&q->smap_ ## F - (void*)&q->fZERO) }
+ #define mkENT(F) { #F ":", -1, offsetof(proc_t, smap_ ## F) }
// make a target field
#define mkOBJ(X) ( (unsigned long *)((void *)&P->fZERO + smaptab[X].offs) )
- static const proc_t *q;
static struct {
const char *item;
int slen;