*fixed some compile issues with xcode.

This commit is contained in:
Wang Renxin 2016-02-15 23:12:33 +08:00
parent 1ae862b2fd
commit 22eeabb807
3 changed files with 27 additions and 2 deletions

View File

@ -1,3 +1,6 @@
Feb. 15 2016
Fixed some compile issues with Xcode
Feb. 11 2016 Feb. 11 2016
Fixed a bug of the EXIT statement with multiple line IF statement Fixed a bug of the EXIT statement with multiple line IF statement
@ -521,7 +524,7 @@ Fixed a crash bug when missing colon in a combined line, thanks to Michael P. We
Fixed a missing lexical cursor stepping bug in INPUT statement Fixed a missing lexical cursor stepping bug in INPUT statement
Mar. 17 2014 Mar. 17 2014
Added an XCode project Added an Xcode project
Added a safe stdin reader function mb_gets Added a safe stdin reader function mb_gets
Fixed a crash bug in INPUT statement Fixed a crash bug in INPUT statement

View File

@ -1,5 +1,13 @@
OS := $(shell uname -s)
IS_APPLE := $(shell echo $(OS)|grep -i darwin)
ifdef IS_APPLE
my_basic : main.o my_basic.o
cc -o output/my_basic_bin main.o my_basic.o -lm
else
my_basic : main.o my_basic.o my_basic : main.o my_basic.o
cc -o output/my_basic_bin main.o my_basic.o -lm -lrt cc -o output/my_basic_bin main.o my_basic.o -lm -lrt
endif
main.o : shell/main.c core/my_basic.h main.o : shell/main.c core/my_basic.h
cc -Os -c shell/main.c -Wno-unused-result cc -Os -c shell/main.c -Wno-unused-result

View File

@ -46,6 +46,9 @@
#include <string.h> #include <string.h>
#include <stdarg.h> #include <stdarg.h>
#include <time.h> #include <time.h>
#ifdef __APPLE__
# include <sys/time.h>
#endif /* __APPLE__ */
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@ -1080,7 +1083,18 @@ static int_t _ticks(void) {
return ret; return ret;
} }
#elif defined __APPLE__ || defined __GNUC__ #elif defined __APPLE__
static int_t _ticks(void) {
struct timespec ts;
struct timeval now;
int rv = gettimeofday(&now, NULL);
if(rv) return 0;
ts.tv_sec = now.tv_sec;
ts.tv_nsec = now.tv_usec * 1000;
return (int_t)(ts.tv_sec * 1000 + ts.tv_nsec / 1000000);
}
#elif defined defined __GNUC__
static int_t _ticks(void) { static int_t _ticks(void) {
struct timespec ts; struct timespec ts;