WINAVR找不到包含空格的包含路径中的文件 [英] WINAVR not finding file in include path with whitespace

查看:108
本文介绍了WINAVR找不到包含空格的包含路径中的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我提供EXTRAINCDIRS的路径(在Makefile中,遵循WINAVR提供的示例)而没有空格时,编译器可以找到我的头文件,但是当我使用包含空格的路径(用引号引起来时,如直接在Makefile中添加注释),它会引发:error: No such file or directory.

When I supply an path for EXTRAINCDIRS (in the Makefile, following the sample provided by WINAVR) without whitespace, the compiler is able to find my header file, but when I use a path containing whitespace (enclosed in quotation marks, as the comments in the Makefile direct), it raises: error: No such file or directory.

"d:/dev/avr/atmega/shared/" # will search files in this dir
"d:/dev/avr/atmega/sha ed/" # will not search this dir for files

我的意思是,评论说:

# List any extra directories to look for include files here.
#     Each directory must be seperated by a space.
#     Use forward slashes for directory separators.
#     For a directory that has spaces, enclose it in quotes.

有什么主意如何让WINAVR正确处理吗?

Any idea how to get WINAVR to handle this correctly?

我在Windows XP上使用程序员的记事本(WINAVR).这是命令行命令:

I'm using Programmer's Notepad (WINAVR) on Windows XP. Here's the command line command:

avr-g++ -c -mmcu=atmega328p -I. -gdwarf-2 -DF_CPU=UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=./main.lst -I"d:/dev/avr/atmega/shared/" -I"d:/dev/avr/atmega/sha -Ied/" -std=gnu99 -MMD -MP -MF .dep/main.o.d main.c -o main.o

推荐答案

正在发生的事情是,我猜测makefile中的其他地方有一行内容如下:

What is happening is that I'm guessing somewhere else in the makefile there is a line that does something like the following:

INCLUDES = $(addprefix -I, $(INCDIRS))

当发生这种情况时,addprefix会将$(INCDIRS)变量中的任何空格视为下一个变量的分隔符,并将在其中添加-I.您可以做的是对空格使用特殊字符,例如'\\',然后在生成命令之前调用替代函数来重新替换空格.类似于以下示例:

When that happens addprefix treats any spaces in the $(INCDIRS) variable as a seperator to the next variable and will add the -I there. What you could do is use a special character for spaces say '\\' and then before the command is generated call a substitute function to resubstitute spaces. Something like the below example:

SPACE = \\
INCDIRS = /home/posey/test$(SPACE)dir

INCLUDES = $(addprefix -I, $(INCDIRS))
REAL_INCLUDES = $(subst $(SPACE), ,$(INCLUDES))

.PHONY : all

all:
    $(info $(REAL_INCLUDES))

如果这没有意义,则可以发布整个makefile,我们可以向您确切显示发生了什么.一旦将空间替换回变量,就无法通过任何其他使用空间定界符的make函数来运行它,而不会发生相同的行为.

If this doesn't make sense you can post the entire makefile and we can show you exactly what's going on. Once the space has been substituted back into the variable you cannot run it through any further make functions that work with space delimiters without the same behavior occurring.

这篇关于WINAVR找不到包含空格的包含路径中的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆