프로그램에서 clock_gettime을 사용하고 있습니다. 나는뿐만 아니라 둘 다 시도했지만 시도하지 못했습니다. 또한 컴파일러 인수에 -lrt를 추가했지만 여전히 동일한 오류가 발생합니다. clock_gettime 및 CLOCK_MONOTONIC의 컴파일 오류
이
은CentOS Linux release 7.2.1511 (Core)
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-4)
GNU ld version 2.23.52.0.1-55.el7 20130226
ldd (GNU libc) 2.17
컴파일러 출력에 : util.h의
CFLAGS = -Wall -g -std=c99
LIBS = -lrt
# Should be equivalent to your list of C files, if you don't build selectively
SRC=$(wildcard *.c)
main: $(SRC)
gcc -o [email protected] $^ $(CFLAGS) $(LIBS)
최고
gcc -o main packet.c connect.c transport.c accept.c main.c close.c util.c receive.c send.c congestion.c -Wall -g -std=c99 -lrt
util.c: In function ‘millis’:
util.c:42:21: error: storage size of ‘t’ isn’t known
struct timespec t;
^
util.c:43:5: warning: implicit declaration of function ‘clock_gettime’ [-Wimplicit-function-declaration]
clock_gettime(CLOCK_MONOTONIC_RAW, &t);
^
util.c:43:19: error: ‘CLOCK_MONOTONIC_RAW’ undeclared (first use in this function)
clock_gettime(CLOCK_MONOTONIC_RAW, &t);
^
메이크
#ifndef UTILS_438_H_
#define UTILS_438_H_
#include "const.h"
#include "data.h"
#include "transport.h"
#include <time.h>
,536,913,632 util.c 10
최고
#include "util.h"
#include <time.h>
#include <stdio.h>
#include <string.h>
, 나는 헤더 (<time.h>
)를 포함하기 전에이
링커 오류가 아니며, '# include' 문제가있는 곳 – yano
컴파일러 경고 및 오류가 발생하는 이유를 알아야합니다. 그것은 링크 문제가 아닙니다. 'time.h'을 포함하고 있기 때문에 경고를해서는 안됩니다. 우리가 당신을 더 도울 수 있도록 [mcve]를 만들 수 있습니까? 어쩌면'c99' 플래그가 방해가 될까요? (그냥 뭔가를 추측하려 함) –
-std = gnu99를 대신 사용 하시겠습니까? – Bonan