gcc 컴파일러로 makefile에 문제가 있습니다. gcc를 직접 사용하는 경우 :GCC makefile은 -std = c99 -lm을 허용하지 않습니다.
gcc -std=c99 -lm tm.c tm_coins.c tm_options.c tm_stock.c tm_utility.c -o tm -Wall -pedantic
모든 것이 정상적으로 작동합니다. 나는 -std-c99와 -lm이 필요하다.
그러나 저는 makefile을 사용하라고 들었습니다. 여기에 제 파일이 있습니다 :
CFLAGS=-ansi -Wall -pedantic
LFLAGS=-std=c99 -lm
CC=gcc
all:tm
tm:tm.o tm_coins.o tm_options.o tm_stock.o tm_utility.o
$(CC) $(LFLAGS) tm.o tm_coins.o tm_options.o tm_stock.o tm_utility.o -o tm $(CFLAGS)
tm.o: tm.h tm.c
$(CC) $(LFLAGS) $(CFLAGS) -c tm.c
tm_coins.o:tm_coins.h tm_coins.c
$(CC) $(LFLAGS) $(CFLAGS) -c tm_coins.c
tm_options:tm_options.h tm_options.c
$(CC) $(LFLAGS) $(CFLAGS) -c tm_options.c
tm_stock:tm_stock.h tm_stock.c
$(CC) $(LFLAGS) $(CFLAGS) -c tm_stock.c
tm_utility:tm_utility.h tm_utility.c
$(CC) $(LFLAGS) $(CFLAGS) -c tm_utility.c
위의 메이크 파일로 아래 오류가 발생합니다. 제 이해는 -std = c99이고 -lm은 작동하지 않습니다. (아래의 첫 번째 줄을 확인합니다. -std = C99 및 -lm하지가)
gcc -ansi -Wall -pedantic -c -o tm_options.o tm_options.c
tm_options.c: In function ‘purchase_ticket’:
tm_options.c:37: error: expected expression before ‘/’ token
tm_options.c:52: error: expected expression before ‘/’ token
tm_options.c:102: warning: ISO C90 forbids mixed declarations and code
tm_options.c: In function ‘display_tickets’:
tm_options.c:239: error: expected expression before ‘/’ token
tm_options.c: In function ‘add_ticket’:
tm_options.c:285: error: expected expression before ‘/’ token
tm_options.c:303: error: expected expression before ‘/’ token
tm_options.c:314: warning: ISO C90 forbids mixed declarations and code
tm_options.c: In function ‘delete_ticket’:
tm_options.c:387: error: expected expression before ‘/’ token
tm_options.c:405: error: expected expression before ‘/’ token
tm_options.c: In function ‘display_coins’:
tm_options.c:461: error: expected expression before ‘/’ token
tm_options.c: In function ‘restock_tickets’:
tm_options.c:501: error: expected expression before ‘/’ token
tm_options.c: In function ‘restock_coins’:
tm_options.c:526: error: expected expression before ‘/’ token
tm_options.c: In function ‘save_data’:
tm_options.c:555: warning: ISO C90 forbids mixed declarations and code
가 어디에 오류가 있을까? 미리 감사드립니다. 다음과 같은 세 가지 규칙에 대한
감사합니다. 너는 .o 확장에 대해 옳았다. 그것은 문제의 절반을 해결했습니다. Paul은 나머지 절반을 해결했습니다. 나는 답을 쪼개는 법을 모른다. :) – Oscar
Hehe :) 어쩌면 이번에는 답을 표기 할 때마다 오해 할 소지가있다 : P 나는 너를 도왔다 니 기뻐. –
너 맞아. 고마워, 폴. 사례가 닫혔습니다. – Oscar