<function>的多重定义

1 c gcc

/tmp/ccTQFVCP.o: In function `whiteSpace':
/home/tommo/fly/flyc/config.c:12: multiple definition of `whiteSpace'
/tmp/cc0ccMfz.o:/home/tommo/fly/flyc/config.c:12: first defined here
/tmp/ccTQFVCP.o: In function `lineEnd':
/home/tommo/fly/flyc/config.c:16: multiple definition of `lineEnd'
/tmp/cc0ccMfz.o:/home/tommo/fly/flyc/config.c:16: first defined here
/tmp/ccTQFVCP.o: In function `makeSubStr':
/home/tommo/fly/flyc/config.c:20: multiple definition of `makeSubStr'
/tmp/cc0ccMfz.o:/home/tommo/fly/flyc/config.c:20: first defined here
Run Code Online (Sandbox Code Playgroud)

我在我的文件config.c中的每个函数都得到了这个

我的每个头文件都有一个#ifndef FILE_H头块.

它为什么这样做?

TARGET   = fly
SRC      = main.c gfx.c transform.c entity.c list.c v3.c config.c airplane.c
CPPFLAGS = -Wall 
LDFLAGS  = -lglfw -lGL -lGLU
DEBUG    = -g

linux: 
    @echo Building for Linux...
    gcc $(CPPFLAGS) $(DEBUG) $(LDFLAGS) $(SRC) -o $(TARGET)
    @echo All done.
clean:
    rm $(TARGET)
help:
    @echo "Available targets for fly"
    @echo " linux: build for linux (default)"
    @echo " clean: clean up directory"

.PHONY: help clean
Run Code Online (Sandbox Code Playgroud)

那是我的Makefile.来自https://github.com/tm1rbrt/fly的 git pull 如果你想尝试自己构建

Mar*_*wis 6

问题是这样的:main.c包含config.c.因此,您可以在config.c中获取两次所有内容.C文件互相包含是非常规的,所以我建议删除包含.