-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Makefile for lua_test | ||
CC = gcc | ||
CXX = g++ | ||
CFLAGS = -g | ||
CXXFLAGS = -g -std=c++14 | ||
OBJS = $(patsubst %c, %o, $(wildcard *.c)) | ||
OBJS += $(patsubst %cpp, %o, $(wildcard *.cpp)) | ||
HEADER = $(wildcard ../include/*.h) | ||
BINS = $(OBJS:%.o=%.out) | ||
PATH_LIBLUA = $(shell cd ../lib && pwd)/lua/prefix | ||
CFLAGS += -I$(PATH_LIBLUA)/include | ||
CXXFLAGS += -I$(PATH_LIBLUA)/include | ||
LDFLAGS += -L$(PATH_LIBLUA)/lib -llua | ||
|
||
.PHONY: all | ||
all: $(BINS) | ||
|
||
.PHONY: clean | ||
clean: | ||
rm -rf $(OBJS) $(DEPS) $(Target) | ||
|
||
$(BINS):$(OBJS) | ||
$(CC) -o $@ $< $(LDFLAGS) | ||
|
||
%.o:%.cpp $(HEADER) | ||
$(CXX) $(CXXFLAGS) -c $< -o $@ | ||
|
||
%.o:%.c $(HEADER) | ||
$(CC) $(CFLAGS) -c $< -o $@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#include <stdio.h> | ||
#include <string.h> | ||
|
||
#include "lauxlib.h" | ||
#include "lua.h" | ||
#include "lualib.h" | ||
|
||
int main(void) { | ||
char buff[256]; | ||
int error; | ||
lua_State *L = luaL_newstate(); | ||
luaL_openlibs(L); /* opens the standard libraries */ | ||
while (fgets(buff, sizeof(buff), stdin) != NULL) { | ||
error = luaL_loadstring(L, buff) || lua_pcall(L, 0, 0, 0); | ||
if (error) { | ||
fprintf(stderr, "%s\n", lua_tostring(L, -1)); | ||
lua_pop(L, 1); /* pop error message from the stack */ | ||
} | ||
} | ||
lua_close(L); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#include <stdio.h> | ||
|
||
int main() { | ||
printf("Hello, World!\n"); | ||
return 0; | ||
} |