解决implicit declaration of function ‘strptime’ [-Wimplicit-function-declaration]

在Makefile里面加上三个宏分别是_GNU_SOURCE 、__USE_XOPEN 、__XOPEN_SOURCE 就可以解决使用strptime函数未声明的编译警告
我的Makefile模板如下:

SOURCE      = $(wildcard *.c)

ECHO = @

TARGET      = offline_tool

all: clean $(TARGET)

#CC             = gcc
CFLAGS      = -g3 -Wall -rdynamic 
#CFLAGS     = -O2 -Wall -rdynamic

GIT_ENV_VERSION=$(shell [[ -x ./git-env.sh ]] && ./git-env.sh)

MODIFIED_D := $(shell date +%F)
MODIFIED_T := $(shell date +%T)
MODIFIED    = "\"$(GIT_ENV_VERSION) $(MODIFIED_D) $(MODIFIED_T)"\"

CFLAGS      += -DVERSION=$(MODIFIED) -D_GNU_SOURCE -D__USE_XOPEN -D_XOPEN_SOURCE

#SRC = $(wildcard *.c)
#OBJ = $(patsubst %.c,%.o,$(SRC))
OBJ = $(SOURCE:%.c=%.o)

INC_PATH    = -I ../libshares/include \
              -I ../libshares/include/mysql/include

LIB_SHARE  += -lpthread -lpcap -ldl -lm -lstdc++ -lhiredis \
              -L ../libshares/libs \
              -lxmlcfg -lxml2 
              -lsenddb -lavroencode.1.3 -lavro -lz -llzma -lopssl -lmysqlclient \


LIB         = $(LIB_SHARE) -Wl,--rpath=../libshares/libs/

%.o:%.c
    $(CC) -c $^ -o $@ $(CFLAGS) $(INC_PATH)



$(TARGET):$(OBJ)
    $(CC) -o $(TARGET) $^ $(LIB)
    cp -f $(TARGET) ../bin/

    $(RM) -f *.o 
    ctags * -R


.PHONY:clean
clean:
    rm -rf *.o
    rm -rf $(TARGET)
    #rm -rf ../bin/$(TARGET)
相关推荐
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页