Skip to content

Commit

Permalink
Makes Linux compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
cslarsen committed May 14, 2016
1 parent a7ecccb commit 3ac6ef8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
5 changes: 3 additions & 2 deletions Makefile
Expand Up @@ -8,14 +8,15 @@ else
endif

LUAJIT := luajit
CXXFLAGS := -W -Wall -g
CXXFLAGS := -W -Wall -g -fpic
TARGETS := libfoo.$(LIBEXT) libfirst.$(LIBEXT)

all: $(TARGETS)
$(LUAJIT) first.lua
$(LUAJIT) foo.lua

lib%.$(LIBEXT): %.o
$(CXX) $(CXXFLAFGS) -fpic -shared $< -o $@
$(CXX) $(CXXFLAFGS) -shared $< -o $@
strip $@

clean:
Expand Down
8 changes: 7 additions & 1 deletion first.cpp
@@ -1,5 +1,6 @@
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <time.h>
#include <unistd.h>

Expand Down Expand Up @@ -50,6 +51,11 @@ EXTERNC const char* random_quote()
"- George Pólya",
};

const int index = arc4random() % sizeof(quotes)/sizeof(char*);
static int index = 0;
if ( !index ) {
srand(clock() ^ getpid());
}

index = rand() % sizeof(quotes)/sizeof(char*);
return quotes[index];
}
2 changes: 2 additions & 0 deletions foo.cpp
@@ -1,5 +1,7 @@
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <stdexcept>
#include <string>
Expand Down

0 comments on commit 3ac6ef8

Please sign in to comment.