Warning:initialization of 'int' from 'char' make integer from pointer without a cast [-Wint-conversion]?

2 Antworten

Vom Fragesteller als hilfreich ausgezeichnet

Das ist definitiv eine der eindeutigeren Meldungen:

Es wird ein int erwartet und Du weist einen char * (Da Du ein Stringliteral angibst) zu. Auch die Warnung excess elements in initializer lässt vermuten, daß die struct eben anders definiert wurde. Du müßtest Dir also dringend mal den Typ Rule genauer anschauen.

ware37 
Fragesteller
 31.12.2023, 01:12
  1. Das ist nicht mein code sondern von der WM DWM
  2. Code:
static const Rule rules[] = { 
{"Gimp", Null, Null, 0, 1, -1}};
0
KarlRanseierIII  31.12.2023, 01:43
@ware37

Eigentlich hatte ich nach dem hier gefragt:

typedef struct {
        const char *class;
        const char *instance;
        const char *title;
        unsigned int tags;
        int isfloating;
        int monitor;
} Rule;

Das sieht soweit passend aus, das Problem muß bei Dir also ein anderes sein. Und der Quellcode (ausm git) lässt sich soweit auch kompilieren.

0
ware37 
Fragesteller
 31.12.2023, 02:08
@KarlRanseierIII
make; make clean install

hat geklappt, yahu, danke fur die Hilfe.Ich hatte es auskommentiert weil ich noch ne extrabar haben wollte und dies und das... leider musste man es selbst machen und die ganzen links zu was dem und hat nicht funktioniert. naja aufjeden, danke

0
ware37 
Fragesteller
 31.12.2023, 01:18
void
applyrules(Client *c)
{
   const char *class, *instance;
   unsigned int i;
   const Rule *r;
   Monitor *m;
   XClassHint ch = { NULL, NULL };

   /* rule matching */
   c->isfloating = 0;
   c->tags = 0;
   XGetClassHint(dpy, c->win, &ch);
   class   = ch.res_class ? ch.res_class : broken;
   instance = ch.res_name ? ch.res_name : broken;

   for (i = 0; i < LENGTH(rules); i++) {
      r = &rules[i];
      if ((!r->title || strstr(c->name, r->title))
      && (!r->class || strstr(class, r->class))
      && (!r->instance || strstr(instance, r->instance))
      && (!r->respectperiod || checkruleperiod()))
      {
         c->iscentered = r->iscentered;
         c->isfloating = r->isfloating;
         c->tags |= r->tags;
         for (m = mons; m && m->num != r->monitor; m = m->next);
         if (m)
            c->mon = m;
      }
   }
   if (ch.res_class)
      XFree(ch.res_class);
   if (ch.res_name)
      XFree(ch.res_name);
   c->tags = c->tags & TAGMASK ? c->tags & TAGMASK : c->mon->tagset[c->mon->seltags];
}
0
KarlRanseierIII  31.12.2023, 01:48
@ware37

Was anderes, hier sieht das so aus:

static const Rule rules[] = {
        /* xprop(1):
         *      WM_CLASS(STRING) = instance, class
         *      WM_NAME(STRING) = title
         */
        /* class      instance    title       tags mask     isfloating   monitor */
        { "Gimp",     NULL,       NULL,       0,            1,           -1 },
        { "Firefox",  NULL,       NULL,       1 << 8,       0,           -1 },
};

Hast Du da dran rumgedoktort?

0

Das erste Feld von Rule ist offenbar ein int, aber Du initialisierst es mit einem String.

Wie ist denn der Typ Rule definiert?

ware37 
Fragesteller
 31.12.2023, 01:10
static const Rule rules[] = { {"Gimp", Null, Null, 0, 1, -1}};
0
ware37 
Fragesteller
 31.12.2023, 01:18
void
applyrules(Client *c)
{
   const char *class, *instance;
   unsigned int i;
   const Rule *r;
   Monitor *m;
   XClassHint ch = { NULL, NULL };

   /* rule matching */
   c->isfloating = 0;
   c->tags = 0;
   XGetClassHint(dpy, c->win, &ch);
   class   = ch.res_class ? ch.res_class : broken;
   instance = ch.res_name ? ch.res_name : broken;

   for (i = 0; i < LENGTH(rules); i++) {
      r = &rules[i];
      if ((!r->title || strstr(c->name, r->title))
      && (!r->class || strstr(class, r->class))
      && (!r->instance || strstr(instance, r->instance))
      && (!r->respectperiod || checkruleperiod()))
      {
         c->iscentered = r->iscentered;
         c->isfloating = r->isfloating;
         c->tags |= r->tags;
         for (m = mons; m && m->num != r->monitor; m = m->next);
         if (m)
            c->mon = m;
      }
   }
   if (ch.res_class)
      XFree(ch.res_class);
   if (ch.res_name)
      XFree(ch.res_name);
   c->tags = c->tags & TAGMASK ? c->tags & TAGMASK : c->mon->tagset[c->mon->seltags];
}
0