【发布时间】:2019-10-31 02:59:04
【问题描述】:
我正在尝试在 dwm 中获取系统托盘。 DWM 是 Suckless 的 X 动态窗口管理器:https://dwm.suckless.org/。要配置 dwm,您需要自己手动添加补丁。我创建了一个包含所有文件的 git 存储库,位于 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
我想要的是它在应用补丁后成功编译,这样我就可以使用系统托盘了。
【问题讨论】:
-
OT:请不要使用制表符进行缩进,尤其是与空格混合时。结果代码在编辑器中显示时是缩进的错误混搭,具体取决于“选项卡”设置在编辑器中显示的宽度
-
OT:变量名(和参数名)应该指明
content或usage(或者更好,两者都有)一个、两个或三个字符名是没有意义的,即使在当前上下文中也是如此跨度> -
这里是一个很好的例子,说明为什么不发布代码链接 在编写此问题后仅 12 个月,
gethub中的链接值已被删除。
标签: c debugging unix freebsd x-dwm