我正在尝试编译一个程序,其中包括windows.h,但对于winbase.h中的每个元素,我都会得到诸如“error:'DCB'未在此作用域中声明”之类的错误。我已将MinGW path包含到所需的头中(还尝试将-I“C:\MinGW\x86\u 64-w64-mingw32\include”-lwindows添加到CFLAGS变量中)。建议?
# Command variables
CC = g++
DEBUG = -Wall -g
CFLAGS = -m64 -I"C:\Program Files\Java\jdk1.7.0_21\include" $(DEBUG) -c
LFLAGS = -m64 -Wl,--add-stdcall-alias -shared $(DEBUG)
COMP_CMD = $(CC) $(CFLAGS) $<
LINK_CMD = $(CC) $(LFLAGS) $? -o $@
HEAD_STUB_CMD = javah -classpath $(CLASS_PATH) $*
# Path variables
CLASS_PATH = ../bin
INCL_PATH = ../include/
SRC_PATH = ../source/
SUB2 = libsercom/
INCL_PATH2 = $(INCL_PATH)$(SUB2)
SRC_PATH2 = $(SRC_PATH)$(SUB2)
# Define a virtual path for .class in the bin directory
vpath %.class $(CLASS_PATH)
all: sercom.dll
#sercom
SERCOM = sercom
$(SERCOM).dll: $(SERCOM).o
$(LINK_CMD)
$(SERCOM).o : $(SRC_PATH2)win$(SERCOM).c $(INCL_PATH2)$(SERCOM).h $(INCL_PATH2)err$(SERCOM).h
$(COMP_CMD)
clean :
\rm *.o *.dll *.h
最佳答案
我建议您打开标题并查看错误列表中列出的名称。很可能它们是用预处理器指令包装的。如果有,尝试在CFLAGS中传递必需的定义。
UPD:例如
#如果(_WIN32_WINNT>=0x0500)
WINBASEAPI BOOL WINAPI GetVolumePathNameA(LPCSTR,LPSTR,DWORD);
如您所见,这需要一个定义。
关于c++ - 对于winbase.h中的元素,g++ makefile“未在此范围内声明”,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/25285229/