Skip to content

Instantly share code, notes, and snippets.

@jonpryor
Created August 20, 2012 20:48
Show Gist options
  • Save jonpryor/3407768 to your computer and use it in GitHub Desktop.
Save jonpryor/3407768 to your computer and use it in GitHub Desktop.
diff --git a/Makefile b/Makefile
index b127bed..e5b75ae 100644
--- a/Makefile
+++ b/Makefile
@@ -2,8 +2,6 @@ TARGET = bin/hello
# C library
CC = cc
-AR = ar cqs
-CLIB = bin/libhello.a
CFLAGS = -Wall -D_REENTRANT -fPIC
CSRC = $(wildcard src/*.c)
COBJS = $(patsubst src/%.c, obj/%.o, $(CSRC))
@@ -19,19 +17,18 @@ CHARPSRC = $(wildcard src/*.cs)
GENERATEDSRC = obj/hello-gen.c
BUNDLEOBJS = obj/hello-bundles.o
-$(TARGET): $(CSHARPEXECUTABLE) $(CLIB)
+all: $(TARGET)
+
+$(TARGET): $(CSHARPEXECUTABLE) $(COBJS)
mkbundle -c -o $(GENERATEDSRC) -oo $(BUNDLEOBJS) $(CSHARPEXECUTABLE)
$(CC) -o $(TARGET) $(CFLAGS) $(GENERATEDSRC) \
`pkg-config --cflags --libs mono-2` \
- $(CLIB) \
+ $(COBJS) \
$(BUNDLEOBJS)
obj/%.o: src/%.c
$(CC) -c $(CFLAGS) -o $@ $<
-$(CLIB): $(COBJS)
- $(AR) $@ $(COBJS)
-
$(CSHARPEXECUTABLE): $(CHARPSRC)
$(CSHARPC) "/out:$(CSHARPEXECUTABLE)" \
$(CSHARPREFERENCES) $(CSHARPFLAGS) $(CHARPSRC)
@@ -39,5 +36,5 @@ $(CSHARPEXECUTABLE): $(CHARPSRC)
clean:
rm -f $(CSHARPEXECUTABLE) \
$(BUNDLEOBJS) $(GENERATEDSRC) \
- $(CLIB) $(COBJS) \
+ $(COBJS) \
$(TARGET)
diff --git a/src/hello.c b/src/hello.c
index a5b03ea..a77bdc2 100644
--- a/src/hello.c
+++ b/src/hello.c
@@ -1,7 +1,7 @@
#include <wchar.h>
-const wchar_t* hello()
+const short* hello()
{
- static const wchar_t* hello_string = L"hello from C";
- return hello_string;
+ static const char hello_string[] = "h\0e\0l\0l\0o\0 \0f\0r\0o\0m\0 \0C\0\0";
+ return (const short*) hello_string;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment