diff --git a/Makefile b/Makefile
index ffe113222d496ccee571b1eff38b3cbfdf83e3b9..c06ccf810cd1c0afafacf1f30c42bcebeb60a91a 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,3 @@
-
 #  "LOG", the circuit editing and simulation system, 5.66
 #  "DigLOG", the digital simulator for LOG.
 #  Copyright (C) 1985, 1990 David Gillespie.
@@ -39,16 +38,19 @@ LIBX11 = -lX11
 
 OTHERLIBS= -lm
 
-CHIPMUNKCC = gcc
+CHIPMUNKCC = g++
 
 CC = $(CHIPMUNKCC)
 
 CHIPMUNKFLAGS = $(ARCH_OPT)
 
-STDC = gnu11
+STDC = c++11
+
+EXTRA_OPTS = -g -w
 
 CFLAGS = $(CHIPMUNKFLAGS) -I$(LOGINC) -I$(XINCLUDEDIR)	\
-	 -DLOGLIB="\"$(LOGLIBDIR)\"" -DF_OK=0 -std=$(STDC) -DCHIPLIB=$(LIBDIR) -g -Wall -Wextra
+	 -DLOGLIB="\"$(LOGLIBDIR)\"" -DF_OK=0 -std=$(STDC) -DCHIPLIB=$(LIBDIR) \
+	 $(EXTRA_OPTS)
 
 ## (3) Choosing default fonts
 ## --------------------------
diff --git a/include/logdig.h b/include/logdig.h
index 595a453045c691da8176ba974e9f6886122cf90c..e928c0a20ca7c7d23e48a1b78a02a8d7345af35d 100644
--- a/include/logdig.h
+++ b/include/logdig.h
@@ -4,17 +4,8 @@
 #include "logdef.h"
 #include <utils/sysglobals.h>
 
-#ifdef LOGDIG_G
-# define vextern
-#else
-# define vextern extern
-#endif
-
-
-
 #define log_16_simtype  16
 
-
 typedef enum {
   log_none, log_zero, log_one
 } log_16_value;
@@ -48,13 +39,21 @@ typedef struct log_16_action {
   void (*hook_plotled) (log_action_t *lact, short x, short y, log_16_value v);
 } log_16_action;
 
-vextern const log_16_viarr log_16_vi;
-vextern const log_16_ivarr log_16_iv;
-vextern const log_16_vbarr log_16_vb;
-vextern const log_16_bvarr log_16_bv;
+const log_16_viarr log_16_vi = {
+								0, 1, 3
+};
 
-#undef vextern
+const log_16_ivarr log_16_iv = {
+								log_none, log_zero, log_one, log_one
+};
 
-#endif /*LOGDIG_H*/
+const log_16_vbarr log_16_vb = {
+								false, false, true
+};
+
+const log_16_bvarr log_16_bv = {
+								log_zero, log_one
+};
 
 
+#endif /*LOGDIG_H*/
diff --git a/src/ana/globals.c b/src/ana/globals.c
index 2e91b4fcdf740071a2d6d2bf4ad5139698267c71..3712aed80ea728afa5f884f968143fbd6af02992 100644
--- a/src/ana/globals.c
+++ b/src/ana/globals.c
@@ -42,9 +42,7 @@ the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 #endif
 
 
-char *AnaProbeVoltStr(AnaResult, Val)
-char *AnaResult;
-double Val;
+char *AnaProbeVoltStr(char *AnaResult, double Val)
 {
   char Outstr[256];
 
@@ -56,9 +54,7 @@ double Val;
 }
 
 
-char *AnaProbeAmpStr(AnaResult, Val)
-char *AnaResult;
-double Val;
+char *AnaProbeAmpStr(char *AnaResult, double Val)
 {
   char Outstr[256];
 
diff --git a/src/diggates.c b/src/diggates.c
index 42d3e23f679980094b09459ffcfe1a20a6a213bc..ffd69ef8449b297674c4b89db3f068726acc4d99 100644
--- a/src/diggates.c
+++ b/src/diggates.c
@@ -618,9 +618,9 @@ void Log_mygates_ascdisp(log_16_action *act_)
 
 		case act_16_new:
 			(*WITH1->hook.getcolor)("CRT", &crtcolor, log_green);
-			m_seefont(&savef);
-			m_seefont(&crtfont);
-			m_setfont(savef);
+			// m_seefont(&savef);
+			// m_seefont(&crtfont);
+			// m_setfont(savef);
 			V.dip = (dispinfo *)Malloc(sizeof(dispinfo));
 			WITH2->info = (void *)V.dip;
 			cleardisp(&V);
@@ -679,7 +679,7 @@ void Log_mygates_ascdisp(log_16_action *act_)
 
 #define map             "1234567890-=qwertyuiop[]asdfghjkl;'\015zxcvbnm,./ \b            "
 #define map_s           "!@#$%^&*()_+QWERTYUIOP{}ASDFGHJKL:\"\015ZXCVBNM<>? \177            "
-/* p2c: diggates.text, line 569: 
+/* p2c: diggates.text, line 569:
  * Warning: Multi-element string constructors not yet supported [136] */
 #define map_c           "12345\036789\0\037\036\021\027\005\022\024\031\025\t\017\020\033\035\001\023\004\006\007\b\n\013\f~`\015"
 
@@ -754,6 +754,3 @@ void Log_mygates_asckbd(log_16_action *act)
 #undef map
 #undef map_s
 #undef map_c
-
-
-
diff --git a/src/logdig.c b/src/logdig.c
index ef5a930487eafdb39fdd2015fb616ac0377e9623..40e66dd74848a6808d183a2670ae72f8387c8b12 100644
--- a/src/logdig.c
+++ b/src/logdig.c
@@ -43,30 +43,8 @@ the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 #include "logdig.h"
 
 
-const log_16_viarr log_16_vi = {
-  0, 1, 3
-};
-
-const log_16_ivarr log_16_iv = {
-  log_none, log_zero, log_one, log_one
-};
-
-const log_16_vbarr log_16_vb = {
-  false, false, true
-};
-
-const log_16_bvarr log_16_bv = {
-  log_zero, log_one
-};
 
 
 
 
 /* All the real stuff is in LOGSIM and LOGSIMA */
-
-
-
-
-
-
-
diff --git a/src/loghier.c b/src/loghier.c
index ba7bfa72d4361a06b4da9485bdb243603d560feb..e94fbd2378ff4c8d5a21b222607a6578aeb192b3 100644
--- a/src/loghier.c
+++ b/src/loghier.c
@@ -229,7 +229,7 @@ char *gateinstname(char *Result, log_grec *g)
 		(*lact->hook2->findattrnum)(g->kind, "inst-of", "CA", &attrinstof);
 		(*lact->hook2->findattrnum)(g->kind, "gate-name", "CA", &attrinstname);
 	}
-	
+
 	if (attrinstname > 0)
 		return strcpy(Result, g->attr[attrinstname - 1].UU.c);
 	else
@@ -349,7 +349,7 @@ void examinetemplate(log_grec *g, log_nrec **pp, long ppsize, int isgeneric, sho
 	xx1 = (kind->x1 + 1) / log_scale0;
 	xx2 = P_imax2((kind->x2 - 1L) / log_scale0, (long)xx1);
 	if (*pnum == NULL)
-		*pnum = Malloc(kind->numpins * 2);
+		*pnum = (short int*) Malloc(kind->numpins * 2);
 
 	numrefs = (short *)Malloc(kind->numpins * 2);
 	FORLIM = kind->numpins;
@@ -654,4 +654,3 @@ void Log_7_ginst(log_action_t *act)
 			break;
 	}
 }
-
diff --git a/src/logsimasm.c b/src/logsimasm.c
index 1b9f1e26698d3298bef5f82625aa7e455bb16410..cd4f3aa97d5c6f4fc0006322036f9f1db4a89150 100644
--- a/src/logsimasm.c
+++ b/src/logsimasm.c
@@ -165,7 +165,7 @@ void callgate(log_16_actionkinds action)
 
 	kind = logsima_action.lact->actgate->kind;
 	g_proc = kind->proc;
-	kip = kind->info;
+	kip = (kindinfo*) kind->info;
 	if (kip->hasproc)
 	{
 		while (*g_proc)
@@ -232,7 +232,7 @@ static char *debug_dasm()
 	if (*g_proc)
 	{
 		tmp = (char*)dasm_16(g_proc, &pc);
-		buf = (char*)Malloc(strlen(tmp) + SAFETY_MARGIN); 
+		buf = (char*)Malloc(strlen(tmp) + SAFETY_MARGIN);
 		strcpy(buf, "\"");
 		strcat(buf, tmp);
 		strcat(buf, "\"  <");
@@ -295,33 +295,33 @@ static log_16_value g_expr()
 	{
 		case 0xa0:  /* AND */
 			ch = (int)g_expr();
-			return and_table[ch][(int)g_expr()];
+			return (log_16_value) and_table[ch][(int)g_expr()];
 
 		case 0xa1:  /* NAND */
 			ch = (int)g_expr();
-			return nand_table[ch][(int)g_expr()];
+			return (log_16_value) nand_table[ch][(int)g_expr()];
 
 		case 0xa2:  /* OR */
 			ch = (int)g_expr();
-			return or_table[ch][(int)g_expr()];
+			return (log_16_value) or_table[ch][(int)g_expr()];
 
 		case 0xa3:  /* NOR */
 			ch = (int)g_expr();
-			return nor_table[ch][(int)g_expr()];
+			return (log_16_value) nor_table[ch][(int)g_expr()];
 
 		case 0xa4:  /* XOR */
 			ch = (int)g_expr();
-			return xor_table[ch][(int)g_expr()];
+			return (log_16_value) xor_table[ch][(int)g_expr()];
 
 		case 0xa5:  /* NOT */
-			return not_table[(int)g_expr()];
+			return (log_16_value) not_table[(int)g_expr()];
 
 		case 0xa6:  /* RISE */
-			nip = g_pinnum()->info;
+			nip = (nodeinfo*) g_pinnum()->info;
 			return (nip->v == log_one && nip->v00 == log_zero) ? log_one : log_zero;
 
 		case 0xa7:  /* FALL */
-			nip = g_pinnum()->info;
+			nip = (nodeinfo*) g_pinnum()->info;
 			return (nip->v == log_zero && nip->v00 == log_one) ? log_one : log_zero;
 
 		case 0xa8:  /* ZERO */
@@ -331,15 +331,15 @@ static log_16_value g_expr()
 			return log_one;
 
 		case 0xaa:  /* SAME */
-			nip = g_pinnum()->info;
+			nip = (nodeinfo*) g_pinnum()->info;
 			return (g_pinnum()->info == nip) ? log_one : log_zero;
 
 		case 0xab:  /* internal node */
 			ch = *g_proc++;
 			if (ch < 128)
-				nip = g_info->ppins[ch - 64]->info;
+				nip = (nodeinfo*) g_info->ppins[ch - 64]->info;
 			else
-				nip = g_info->ppins[ch + ((*g_proc++) << 7) - (32*128+64)]->info;
+				nip = (nodeinfo*) g_info->ppins[ch + ((*g_proc++) << 7) - (32*128+64)]->info;
 			return nip->v;
 
 		case 0xac:  /* pvar */
@@ -351,20 +351,20 @@ static log_16_value g_expr()
 					? log_one : log_zero;
 
 		case 0xad:  /* FIX */
-			return fix_table[(int)g_expr()];
+			return (log_16_value) fix_table[(int)g_expr()];
 
 		case 0xb0:  /* high pin */
-			nip = g_pins[*g_proc++]->info;
+			nip = (nodeinfo*) g_pins[*g_proc++]->info;
 			if (TRACE_VAL) nc_printf(" Value of %p is %d\n", nip, (int)nip->v - 1);
 			return nip->v;
 
 		case 0xb1:  /* STRONG */
-			nip = g_pinnum()->info;
+			nip = (nodeinfo*) g_pinnum()->info;
 			return nip->truev;
 
 			case16(0xc0):  /* pin */
 				case16(0xd0):
-					nip = g_pins[ch & 0x1f]->info;
+			    nip = (nodeinfo*) g_pins[ch & 0x1f]->info;
 			if (TRACE_VAL) nc_printf(" Value of %p is %d\n", nip, (int)nip->v - 1);
 			return nip->v;
 
@@ -534,7 +534,7 @@ if_skip:
 
 			case 0x1c:  /* PULLDN */
 				np = g_pinnum();
-				nip = np->info;
+				nip = (nodeinfo*) np->info;
 				if (nip->defv == log_one)
 					record_conflict(np);
 				else
@@ -543,7 +543,7 @@ if_skip:
 
 			case 0x1d:  /* PULLUP */
 				np = g_pinnum();
-				nip = np->info;
+				nip = (nodeinfo*) np->info;
 				if (nip->defv == log_zero)
 					record_conflict(np);
 				else
@@ -566,7 +566,7 @@ out_node:
 				switch (g_expr())
 				{
 					case log_zero:
-						nip = np->info;
+						nip = (nodeinfo*) np->info;
 						if (TRACE_VAL) nc_printf(" Output 0 to %p (was %d)\n", nip, nip->v0);
 						if (nip->v0 == log_one)
 							record_conflict(np);
@@ -575,7 +575,7 @@ out_node:
 						break;
 
 					case log_one:
-						nip = np->info;
+						nip = (nodeinfo*) np->info;
 						if (TRACE_VAL) nc_printf(" Output 1 to %p (was %d)\n", nip, nip->v0);
 						if (nip->v0 == log_zero)
 							record_conflict(np);
@@ -595,7 +595,7 @@ out_node:
 oc_out_node:
 				if (g_expr() == log_zero)
 				{
-					nip = np->info;
+					nip = (nodeinfo*) np->info;
 					if (TRACE_VAL) nc_printf(" Output 0 to %p (was %d)\n", nip, nip->v0);
 					if (nip->v0 == log_one)
 						record_conflict(np);
@@ -683,7 +683,7 @@ void executegates(int *active, log_grec *g)
 			g_proc = g->kind->proc;
 			g_pins = g->pin;
 			g_gate = g;
-			g_info = g->info;
+			g_info = (gateinfo*) g->info;
 			g_vars = (long)g->vars;
 			g_stmts();
 			g->vars = (na_long)g_vars;
@@ -692,4 +692,3 @@ void executegates(int *active, log_grec *g)
 	}
 
 }
-
diff --git a/src/logsimh.c b/src/logsimh.c
index dc65bbbd768b71e7d04ad63a3f25c2450abd09d2..33ac4fa784fa7295071ed89a39f92338e098096b 100644
--- a/src/logsimh.c
+++ b/src/logsimh.c
@@ -1664,7 +1664,7 @@ static void parsegates(struct LOC_compilepage *LINK)
 				if (i == first)
 					i++;
 				else
-					na_exch((void *)(&glist[i - 1]), (void *)(&glist[first - 1]),
+					na_exch((long *)(&glist[i - 1]), (long *)(&glist[first - 1]),
 							sizeof(gaterec));
 				P_setunion(defs, defs, glist[first - 1].outs);
 				first++;
@@ -1685,7 +1685,7 @@ static void parsegates(struct LOC_compilepage *LINK)
 					j = i;
 				}
 			}
-			na_exch((void *)(&glist[j - 1]), (void *)(&glist[first - 1]),
+			na_exch((long *)(&glist[j - 1]), (long *)(&glist[first - 1]),
 					sizeof(gaterec));
 			P_setunion(defs, defs, glist[first - 1].outs);
 			first++;
@@ -1997,23 +1997,17 @@ static instrrec *makeinstr3(instrops code, instrrec *a1, instrrec *a2, instrrec
 	return ip;
 }
 
-static instrrec *makefix0(arg, LINK)
-	instrrec *arg;
-	struct LOC_compilepage *LINK;
+static instrrec *makefix0(instrrec *arg, struct LOC_compilepage *LINK)
 {
 	return (makeinstr1(op_fix0, arg, LINK));
 }
 
-static instrrec *makefix1(arg, LINK)
-	instrrec *arg;
-	struct LOC_compilepage *LINK;
+static instrrec *makefix1(instrrec *arg, struct LOC_compilepage *LINK)
 {
 	return (makeinstr1(op_fix1, arg, LINK));
 }
 
-static instrrec *copytree(ip, LINK)
-	instrrec *ip;
-	struct LOC_compilepage *LINK;
+static instrrec *copytree(instrrec *ip, struct LOC_compilepage *LINK)
 {
 	instrrec *Result, *ip2;
 	noderec *WITH;
@@ -2047,7 +2041,7 @@ static instrrec *copytree(ip, LINK)
 	return Result;
 }
 
-static void replacetree(instrrec **ip, instrrec **ip2, struct LOC_compilepage *LINK)
+static void replacetree(instrrec **ip, instrrec *ip2, struct LOC_compilepage *LINK)
 {
 	disposetree(ip, LINK);
 	*ip = ip2;
@@ -2754,7 +2748,7 @@ static void untrail(trailrec *tp, struct LOC_simplstmt *LINK)
 	while (tp != NULL)
 	{
 		WITH = &LINK->LINK->LINK->things[tp->num];
-		na_exch((void *)(&WITH->poss), (void *)(&tp->oldposs), sizeof(long));
+		na_exch((long *)(&WITH->poss), (long *)(&tp->oldposs), sizeof(long));
 		tflag = WITH->strong;
 		WITH->strong = tp->oldstrong;
 		tp->oldstrong = tflag;
@@ -2849,7 +2843,7 @@ static void builddefvusev(instrrec *ip, long *defv, long *usev, struct LOC_simpl
 	}
 }
 
-static void checkdefvusev(instrrec *ip, long *defv, long *usev, uint *good, struct LOC_simplstmt *LINK)
+static void checkdefvusev(instrrec *ip, long *defv, long *usev, bool *good, struct LOC_simplstmt *LINK)
 {
 	instrrec *ip2;
 	long i;
@@ -2889,7 +2883,8 @@ static void trymoveif(struct LOC_simplstmt *LINK)
 {
 	instrrec *ip2, *ip3, **ipp2;
 	long *defv1, *usev1, *defv2, *usev2;
-	int good1, good2, localchg;
+	bool good1, good2;
+	int localchg;
 	instrops otherif;
 	size_t i;