gpt4 book ai didi

c - 我在修补 DWM 时遇到错误,此处不允许使用有关函数定义的内容

转载 作者:行者123 更新时间:2023-11-30 14:38:22 26 4
gpt4 key购买 nike

我正在尝试在 dwm 中获取系统托盘。 DWM是suckless的X动态窗口管理器:https://dwm.suckless.org/ 。要配置 dwm,您需要自己手动添加补丁。我制作了一个包含所有文件的 git 存储库,位于 https://github.com/domianter34/dwm/tree/master/dwm ,但问题似乎仅与 dwm.c 文件有关。另外,在我添加的 git 存储库中,我包含了我添加过的所有补丁,因此我没有针对库存 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

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

最佳答案

我看到的第一个错误:

关于:

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 '}'

关于c - 我在修补 DWM 时遇到错误,此处不允许使用有关函数定义的内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56632615/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com