diff --git a/compiler/Makefile.unix b/compiler/Makefile.unix
index 9fc9bbd..70de489 100755
--- a/compiler/Makefile.unix
+++ b/compiler/Makefile.unix
@@ -56,6 +56,9 @@ LIBS = -lshell32 -lpsapi -limagehlp -lwsock32 `pkg-config --libs libcrypto` -lz
 EXE = .exe
 endif
 
+AR ?= ar
+RANLIB ?= ranlib
+
 CXXFLAGS ?= -g -Wall -Wuninitialized
 ##CXXFLAGS ?= -O3 -Wall -Wuninitialized $(ARCHFLAGS)
 CXXFLAGS += -Wno-parentheses $(addprefix -I, $(subprojects)) -DINSTALL_PREFIX='"$(prefix)"'
@@ -120,7 +126,7 @@ else
 ifneq ($(findstring MINGW32, $(system)),)
 	CXXFLAGS += -O1 -I/usr/include
 else
-	CXXFLAGS += -O1 -fPIC
+	CXXFLAGS += -O1 -fPIC -D__USE_MINGW_ANSI_STDIO
 endif
 endif
 
@@ -224,16 +230,16 @@ else
 ifneq ($(findstring MINGW32, $(system)),)
     libfaust.a : $(objects) libcode.o libmain.o global.o
 	rm -f $@
-	ar cq $@ $(objects) libcode.o libmain.o global.o
-	ranlib $@
+	$(AR) cq $@ $(objects) libcode.o libmain.o global.o
+	$(RANLIB) $@
 
     libfaust.dll : $(objects) libcode.o libmain.o global.o
 	$(CXX) -shared $(LDFLAGS) $(objects) libcode.o libmain.o global.o -o libfaust.dll `$(LLVM_CONFIG) --ldflags` $(LLVMLIBS) $(CLANGLIBS) $(LIBS) -lpthread
 else
     libfaust.a : $(objects) libcode.o libmain.o global.o
 	rm -f $@
-	ar cq $@ $(objects) libcode.o libmain.o global.o
-	ranlib $@
+	$(AR) cq $@ $(objects) libcode.o libmain.o global.o
+	$(RANLIB) $@
 
     libfaust.so : $(objects) libcode.o libmain.o global.o
 	$(CXX) -shared -fPIC $(LDFLAGS) $(objects) libcode.o libmain.o global.o -o libfaust.so `$(LLVM_CONFIG) --ldflags` $(LLVM_STATIC_LIBS) $(CLANGLIBS) -ldl -lcrypto -lstdc++
diff --git a/compiler/generator/fir_to_fir.cpp b/compiler/generator/fir_to_fir.cpp
index 1ceb78b..6fa8cfe 100644
--- a/compiler/generator/fir_to_fir.cpp
+++ b/compiler/generator/fir_to_fir.cpp
@@ -40,7 +40,7 @@ static bool sortArrayDeclarationsAux(StatementInst* a, StatementInst* b)
                 ArrayTyped* array_typed2 = dynamic_cast<ArrayTyped*>(inst2->fType);
                 if (array_typed2) {
                     return (array_typed1->fSize == array_typed2->fSize) 
-                            ? (long)array_typed1 > (long)array_typed1
+                            ? (intptr_t)array_typed1 > (intptr_t)array_typed1
                             : array_typed1->fSize > array_typed2->fSize;
                 } 
             }
diff --git a/compiler/generator/floats.cpp b/compiler/generator/floats.cpp
index df6655a..b920077 100644
--- a/compiler/generator/floats.cpp
+++ b/compiler/generator/floats.cpp
@@ -51,10 +51,10 @@ const Typed::VarType itfloat()
             return Typed::kDouble;
         case 3:
             return Typed::kQuad;
-        default:
-            assert(false);
-            break;
     }
+
+    assert(false);
+    return Typed::kFloat;
 }
 
 const char* ifloat() { return floatname[gGlobal->gFloatSize]; }
diff --git a/compiler/generator/instructions.hh b/compiler/generator/instructions.hh
index 7f5b3bf..46bb67f 100644
--- a/compiler/generator/instructions.hh
+++ b/compiler/generator/instructions.hh
@@ -1782,6 +1782,7 @@ struct InstBuilder
         } else {
             assert(false);
         }
+        return NULL;
     }
     
     static ValueInst* genArrayNumInst(Typed::VarType ctype, int size)
@@ -1795,6 +1796,7 @@ struct InstBuilder
         } else {
             assert(false);
         }
+        return NULL;
     }
 
     static IntNumInst* genIntNumInst(int num, int size = 1) { return new IntNumInst(num); }
diff --git a/compiler/generator/llvm/clang_code_container.hh b/compiler/generator/llvm/clang_code_container.hh
index c6bd162..48be0ec 100644
--- a/compiler/generator/llvm/clang_code_container.hh
+++ b/compiler/generator/llvm/clang_code_container.hh
@@ -62,7 +62,7 @@ class ClangCodeContainer : public virtual CodeContainer {
         
         virtual void produceInternal() { fContainer->produceInternal(); }
     
-        CodeContainer* createScalarContainer(const string& name, int sub_container_type) { assert(false); } // Not used
+        CodeContainer* createScalarContainer(const string& name, int sub_container_type) { assert(false); return NULL; } // Not used
 
         static CodeContainer* createContainer(const string& name, int numInputs, int numOutputs);
 
diff --git a/compiler/generator/llvm/llvm_instructions.hh b/compiler/generator/llvm/llvm_instructions.hh
index 795c75e..f6f1203 100644
--- a/compiler/generator/llvm/llvm_instructions.hh
+++ b/compiler/generator/llvm/llvm_instructions.hh
@@ -1544,6 +1544,7 @@ class LLVMInstVisitor : public InstVisitor, public LLVMTypeHelper {
             } else {
                 // Default
                 assert(false);
+                return NULL;
             }
             
             return fBuilder->CreateInBoundsGEP(res_load_ptr, fCurValue);
@@ -1701,6 +1702,7 @@ class LLVMInstVisitor : public InstVisitor, public LLVMTypeHelper {
             } else {
                 // default
                 assert(false);
+                return;
             }
             
             // Compute value to be stored, result is in fCurValue
diff --git a/compiler/propagate/labels.cpp b/compiler/propagate/labels.cpp
index 2943578..74ed031 100644
--- a/compiler/propagate/labels.cpp
+++ b/compiler/propagate/labels.cpp
@@ -143,7 +143,8 @@ static Tree normalizeLabel(Tree label, Tree path)
 		return cons(label, path);
 	} else {
 		Sym s;
-		assert (isSym(label->node(),&s));
+                bool is_sym = isSym(label->node(),&s);
+		assert (is_sym);
 		return concatPath(label2path(name(s)),path);
 	}
 }
diff --git a/compiler/tlib/compatibility.hh b/compiler/tlib/compatibility.hh
index 3783306..dd0646b 100644
--- a/compiler/tlib/compatibility.hh
+++ b/compiler/tlib/compatibility.hh
@@ -26,6 +26,14 @@
 
 unsigned faust_alarm(unsigned seconds);
 
+
+#ifdef __MINGW32__
+#define faust_mkdir(path, attribute) mkdir(path)
+#else
+#define faust_mkdir(path, attribute) mkdir(path, attribute)
+#endif
+
+
 #ifdef _WIN32
 #include <windows.h>
 #include <time.h>
@@ -39,33 +47,48 @@ unsigned faust_alarm(unsigned seconds);
 #endif
 #define YY_NO_UNISTD_H 1
 
+#define GCC_VERSION (__GNUC__ * 10000                 \
+                     + __GNUC_MINOR__ * 100           \
+                     + __GNUC_PATCHLEVEL__)
+
+#if GCC_VERSION < 40700
 struct timezone 
 {
 	int  tz_minuteswest; /* minutes W of Greenwich */
 	int  tz_dsttime;     /* type of dst correction */
 };
+#endif
 
 #define alarm(x) 0
+
 #ifndef __MINGW32__
 // mingw has these in its headers.
 #define strdup _strdup
 #define snprintf _snprintf
 #endif
+
+
 extern "C" {
 #if (_MSC_VER<=1700)
     double  rint(double nr);
 #endif
+
 int gettimeofday(struct timeval *tv, struct timezone *tz);
 int chdir(const char* path);
-int mkdir(const char* path, unsigned int attribute);
+#if _MSC_VER
+  int mkdir(const char* path);
+#endif
 char* getcwd(char* str, int size);
 int isatty(int file);
 }
+
+
 void getFaustPathname(char* str, unsigned int size);
 void getFaustPathname(char* str, unsigned int size);
 char* realpath(const char* path, char resolved_path[PATH_MAX]);
 char* basename(const char* fullpath);
 
+
 #ifdef  NDEBUG
 #undef assert
 #define assert(_Expression) do { bool bTest = (_Expression) != 0; } while (0)
@@ -84,10 +107,12 @@ char* basename(const char* fullpath);
 	#define S_IRWXU 0
 #endif
 
+#if !defined(__MINGW32__) || GCC_VERSION < 40903
 #define S_IRWXG 0
 #define S_IROTH 0
 #define S_IXOTH 0
 #define DIRSEP '\\'
+#endif
 
 #undef min
 #undef max
@@ -100,6 +125,8 @@ char* basename(const char* fullpath);
 
 void getFaustPathname(char* str, unsigned int size);
 
-#endif
+#endif // _WIN32
+
+
 
 #endif
diff --git a/compiler/utils/files.cpp b/compiler/utils/files.cpp
index 39e18ed..0bb90d7 100644
--- a/compiler/utils/files.cpp
+++ b/compiler/utils/files.cpp
@@ -61,7 +61,7 @@ int mkchdir(string dirname)
 {
     getCurrentDir();
     if (gGlobal->gCurrentDir != "") {
-		int status = mkdir(dirname.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
+		int status = faust_mkdir(dirname.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
 		if (status == 0 || errno == EEXIST) {
 			if (chdir(dirname.c_str()) == 0) {
 				return 0;
@@ -78,7 +78,7 @@ int	makedir(string dirname)
 {
     getCurrentDir();
     if (gGlobal->gCurrentDir != "") {
-		int status = mkdir(dirname.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
+		int status = faust_mkdir(dirname.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
 		if (status == 0 || errno == EEXIST) {
 			return 0;
 		}
