Warning:initialization of 'int' from 'char' make integer from pointer without a cast [-Wint-conversion]?
Versteht ihr den Error und wisst wie man ihn fixt?
Linux ist C aber ich kann nur Python.
Das debugging ist in c eine herrausverderung vorallem wenn man das erste mal dran arbeitet ' '
2 Antworten
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.
- Das ist nicht mein code sondern von der WM DWM
- Code:
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.
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
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];
}
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?
Das erste Feld von Rule ist offenbar ein int, aber Du initialisierst es mit einem String.
Wie ist denn der Typ Rule definiert?
static const Rule rules[] = { {"Gimp", Null, Null, 0, 1, -1}};
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];
}