0

我正在尝试在 dwm 中获取系统托盘。DWM 是 Suckless 的 X 动态窗口管理器:https ://dwm.suckless.org/ 。要配置 dwm,您需要自己手动添加补丁。我制作了一个包含所有文件的 git repo,位于https://github.com/domianter34/dwm/tree/master/dwm,但问题似乎只出在 dwm.c 文件上。同样在我添加的 git repo 中,我包含了我曾经添加的所有补丁,所以我没有针对股票 dwm 进行补丁。我也在 FreeBSD 上编译这个,但我认为操作系统在这个问题的上下文中是无关紧要的。先感谢您。

我不知道关于 C 编程的第一件事,因此我在这里问。从我所读到的关于该错误的信息中,它似乎表明我在某处缺少一个括号,但是在它指向我的那一行,一切似乎都井井有条。

这是确切的错误:

rm -f dwm drw.o dwm.o util.o dwm-6.2.tar.gz
dwm build options:
CFLAGS   = -std=c99 -pedantic -Wall -Wno-deprecated-declarations -Os -g -I/usr/local/include -I/usr/local/include/freetype2 -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=2 -DVERSION="6.2" -DXINERAMA
LDFLAGS  = -L/usr/local/lib -lX11 -lXinerama -lfontconfig -lXft -lXrender
CC       = cc
cc -c -std=c99 -pedantic -Wall -Wno-deprecated-declarations -Os -g -I/usr/local/include -I/usr/local/include/freetype2 -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=2 -DVERSION=\"6.2\" -DXINERAMA drw.c
cc -c -std=c99 -pedantic -Wall -Wno-deprecated-declarations -Os -g -I/usr/local/include -I/usr/local/include/freetype2 -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=2 -DVERSION=\"6.2\" -DXINERAMA dwm.c
dwm.c:796:10: warning: implicitly declaring library function 'snprintf' with type 'int (char *, unsigned long, const char *, ...)' [-Wimplicit-function-declaration]
                snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n - m->nmaster);
                ^
dwm.c:796:10: note: include the header <stdio.h> or explicitly provide a declaration for 'snprintf'
dwm.c:975:1: error: function definition is not allowed here
{
^
dwm.c:1001:1: error: function definition is not allowed here
{
^
dwm.c:1010:1: error: function definition is not allowed here
{
^
dwm.c:1025:1: error: function definition is not allowed here
{
^
dwm.c:1051:1: error: function definition is not allowed here
{
^
dwm.c:1075:1: error: function definition is not allowed here
{
^
dwm.c:1085:1: error: function definition is not allowed here
{
^
dwm.c:1103:1: error: function definition is not allowed here
{
^
dwm.c:1113:1: error: function definition is not allowed here
{
^
dwm.c:1138:1: error: function definition is not allowed here
{
^
dwm.c:1159:1: error: function definition is not allowed here
{
^
dwm.c:1177:1: error: function definition is not allowed here
{
^
dwm.c:1185:1: error: function definition is not allowed here
{
^
dwm.c:1196:1: error: function definition is not allowed here
{
^
dwm.c:1212:1: error: function definition is not allowed here
{
^
dwm.c:1228:1: error: function definition is not allowed here
{
^
dwm.c:1298:1: error: function definition is not allowed here
{
^
dwm.c:1308:1: error: function definition is not allowed here
{
^
dwm.c:1329:1: error: function definition is not allowed here
{
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
1 warning and 20 errors generated.
*** Error code 1

Stop.
make: stopped in /usr/home/dominic/Source/dwm

我想要的是它在应用补丁的情况下成功编译,这样我就可以使用系统托盘了。

4

1 回答 1

2

我看到的第一个错误:

关于:

void
expose(XEvent *e)
{
    Monitor *m;
    XExposeEvent *ev = &e->xexpose;

    if (ev->count == 0 && (m = wintomon(ev->window))) { 
        drawbar(m);
        if (m == selmon)
                   updatesystray();
}

稍微重写以暴露问题:

void
expose(XEvent *e)
{
    Monitor *m;
    XExposeEvent *ev = &e->xexpose;

    if (ev->count == 0 && (m = wintomon(ev->window))) 
    {   
        drawbar(m);
        if (m == selmon)
                       updatesystray();
    }
// this is missing, right here,  the final closing brace '}'
于 2019-06-17T14:45:10.230 回答