diff -ruN klic-3.003-2001-12-30/ChangeLog klic-3.003-2001-12-31/ChangeLog
--- klic-3.003-2001-12-30/ChangeLog	Sun Dec 30 17:14:44 2001
+++ klic-3.003-2001-12-31/ChangeLog	Mon Dec 31 12:04:47 2001
@@ -1,3 +1,7 @@
+2001-12-31 TAKAGI Yusuke <takagi@ueda.info.waseda.ac.jp>
+
+	* include/klic/stdc.h: new file.
+
 2001-12-30 TAKAGI Yusuke <takagi@ueda.info.waseda.ac.jp>
 
 	* include/klic/extinl.h: remove.
diff -ruN klic-3.003-2001-12-30/include/Makefile.tail klic-3.003-2001-12-31/include/Makefile.tail
--- klic-3.003-2001-12-30/include/Makefile.tail	Sun Dec 30 17:14:44 2001
+++ klic-3.003-2001-12-31/include/Makefile.tail	Mon Dec 31 12:04:47 2001
@@ -11,7 +11,7 @@
 SHMHEADERS = # klic/shm.h klic/shm_machine.h
 
 HEADERS = klic/config.h klic/alloc.h klic/atomstuffs.h \
-	klic/klichdr.h \
+	klic/klichdr.h klic/stdc.h \
 	klic/basic.h klic/bb.h klic/control.h \
 	klic/functorstuffs.h klic/predinfo.h \
 	klic/gb.h \
diff -ruN klic-3.003-2001-12-30/include/klic/basic.h klic-3.003-2001-12-31/include/klic/basic.h
--- klic-3.003-2001-12-30/include/klic/basic.h	Sat Dec 29 12:46:20 2001
+++ klic-3.003-2001-12-31/include/klic/basic.h	Mon Dec 31 12:04:47 2001
@@ -9,6 +9,7 @@
 #define _KLIC_BASIC_H_
 
 #include <stdio.h>
+#include <klic/stdc.h>  /* const, volatile */
 #include <klic/config.h>
 
 #ifdef MAIN
@@ -17,11 +18,6 @@
 #else
 #define Extern		extern
 #define Init(x)
-#endif
-
-#ifndef __STDC__
-#define const
-#define volatile
 #endif
 
 #ifdef __GNUC__
diff -ruN klic-3.003-2001-12-30/include/klic/control.h klic-3.003-2001-12-31/include/klic/control.h
--- klic-3.003-2001-12-30/include/klic/control.h	Sat Dec 29 12:46:20 2001
+++ klic-3.003-2001-12-31/include/klic/control.h	Mon Dec 31 12:04:47 2001
@@ -11,7 +11,7 @@
 #include <klic/alloc.h>  /* klic_interrupt */
 
 /* runtime/faisus.c */
-extern q* interrupt_goal(q* allocp, struct predicate* pred, q* reasonp);
+extern q* interrupt_goal(q* allocp, const struct predicate* pred, q* reasonp);
 extern int check_stack_for_alternatively(q* allocp, q* reasonp);
 
 
diff -ruN klic-3.003-2001-12-30/include/klic/g_basic.h klic-3.003-2001-12-31/include/klic/g_basic.h
--- klic-3.003-2001-12-30/include/klic/g_basic.h	Sat Dec 29 12:46:20 2001
+++ klic-3.003-2001-12-31/include/klic/g_basic.h	Mon Dec 31 12:08:05 2001
@@ -8,6 +8,8 @@
 #ifndef _KLIC_G_BASIC_H_
 #define _KLIC_G_BASIC_H_
 
+#include <klic/stdc.h>  /* CONCATENATE*, STRINGIFY */
+
 /* external module/class reference */
 
 #define G_USE_PREDICATE(name) \
@@ -55,26 +57,13 @@
 #define G_SUSPP(x) suspp(x)
 #define G_PREDP(x) predp(x)
 
-#ifdef __STDC__
-#define G_rappend1(class,post) class##_g_##post
-#define G_functor(fa) functor_##fa
-#define G_atom(fa) atom_##fa
-#define G_guard1(class,fa) class##_g_guard_##fa
-#define G_body1(class,fa) class##_g_body_##fa
-#define G_stringify1(s) #s
-#define G_stringify(s) G_stringify1(s)
-#else
-#define G_rappend1(class,post) class/**/_g_/**/post
-#define G_functor(fa) functor_/**/fa
-#define G_atom(fa) atom_/**/fa
-#define G_guard1(class,fa) class/**/_g_guard_/**/fa
-#define G_body1(class,fa) class/**/_g_body_/**/fa
-#define G_stringify(s) "s"
-#endif
-
-#define G_rappend0(class,post) G_rappend1(class,post)
-#define G_guard0(class,fa) G_guard1(class,fa)
-#define G_body0(class,fa) G_body1(class,fa)
+#define G_functor(fa)  CONCATENATE(functor_, fa)
+#define G_atom(fa)     CONCATENATE(atom_, fa)
+#define G_stringify(s) STRINGIFY(s)
+
+#define G_rappend0(class,post) CONCATENATE_3(class, _g_, post)
+#define G_guard0(class,fa)     CONCATENATE_3(class, _g_guard_, fa)
+#define G_body0(class,fa)      CONCATENATE_3(class, _g_body_, fa)
 
 
 /** G_HEAPALLOC: procedure
diff -ruN klic-3.003-2001-12-30/include/klic/gb.h klic-3.003-2001-12-31/include/klic/gb.h
--- klic-3.003-2001-12-30/include/klic/gb.h	Sat Dec 29 12:46:20 2001
+++ klic-3.003-2001-12-31/include/klic/gb.h	Mon Dec 31 12:04:47 2001
@@ -8,6 +8,7 @@
 #ifndef _KLIC_GB_H_
 #define _KLIC_GB_H_
 
+#include <klic/stdc.h>  /* CONCATENATE */
 #include <klic/functorstuffs.h>  /* functoratom, arityof */
 #include <klic/control.h>  /* check_stack_for_alternatively */
 
@@ -184,11 +185,7 @@
 
 /* Generic Object Manipulation */
 
-#ifdef __STDC__
-#define TableName(x)	(x##_g_data_method_table)
-#else
-#define TableName(x)	(x/**/_g_data_method_table)
-#endif
+#define TableName(x)	CONCATENATE(x, _g_data_method_table)
 
 #define jump_if_not_in_class(x, class, lab)				\
 do{									\
diff -ruN klic-3.003-2001-12-30/include/klic/gc_macro.h klic-3.003-2001-12-31/include/klic/gc_macro.h
--- klic-3.003-2001-12-30/include/klic/gc_macro.h	Sat Dec 29 12:46:20 2001
+++ klic-3.003-2001-12-31/include/klic/gc_macro.h	Mon Dec 31 12:04:47 2001
@@ -8,6 +8,7 @@
 #ifndef _KLIC_GC_MACRO_H_
 #define _KLIC_GC_MACRO_H_
 
+#include <klic/stdc.h>  /* CONCATENATE */
 #include <klic/basic.h>  /* fatal, debug_printf, klic_fprintf, klic_putc */
 
 extern q GC_wakeup_g_new();
@@ -57,13 +58,7 @@
 /* runtime/generic.c */
 extern q GC_MAKE_HOOK_VAR(struct consumer_object* obj);
 
-#ifdef __STDC__
-#define GC_method_table1(class) class##_g_data_method_table
-#else
-#define GC_method_table1(class) class/**/_g_data_method_table
-#endif
-
-#define GC_method_table0(class) GC_method_table1(class)
+#define GC_method_table0(class)  CONCATENATE(class, _g_data_method_table)
 
 #define GC_method_table GC_method_table0(GC_CLASS_NAME())
 
diff -ruN klic-3.003-2001-12-30/include/klic/gd_macro.h klic-3.003-2001-12-31/include/klic/gd_macro.h
--- klic-3.003-2001-12-30/include/klic/gd_macro.h	Sat Dec 29 12:47:41 2001
+++ klic-3.003-2001-12-31/include/klic/gd_macro.h	Mon Dec 31 12:04:47 2001
@@ -8,6 +8,7 @@
 #ifndef _KLIC_GD_MACRO_H_
 #define _KLIC_GD_MACRO_H_
 
+#include <klic/stdc.h>  /* CONCATENATE */
 #include <klic/functorstuffs.h>  /* functors, arities, FUNCTORNUMBERBASE */
 #include <klic/basic.h>  /* fatal, klic_fprintf, klic_putc */
 
@@ -39,23 +40,13 @@
 
 #define GD_OBJ(x) G_MAKEFUNCTOR(x)
 
-#ifdef __STDC__
-#define GD_method_table1(class) class##_g_data_method_table
-#else
-#define GD_method_table1(class) class/**/_g_data_method_table
-#endif
-
-#define GD_method_table0(class)  GD_method_table1(class)
+#define GD_method_table0(class)  CONCATENATE(class, _g_data_method_table)
 #define GD_method_table GD_method_table0(GD_CLASS_NAME())
 
 #define GD_USE_CLASS(class) \
 extern struct data_object_method_table GD_method_table0(class)
 
-#ifdef __STDC__
 #define GD_CLASS_NAME_STRING G_stringify(GD_CLASS_NAME())
-#else
-#define GD_CLASS_NAME_STRING 0
-#endif
 
 #define GD_FAIL(errmsg)  fatal(errmsg)
 #define GD_UNIFY_FAIL \
diff -ruN klic-3.003-2001-12-30/include/klic/generic.h klic-3.003-2001-12-31/include/klic/generic.h
--- klic-3.003-2001-12-30/include/klic/generic.h	Thu Dec 27 19:15:58 2001
+++ klic-3.003-2001-12-31/include/klic/generic.h	Mon Dec 31 12:04:47 2001
@@ -8,6 +8,7 @@
 #ifndef _KLIC_GENERIC_H_
 #define _KLIC_GENERIC_H_
 
+#include <klic/stdc.h>  /* CONCATENATE */
 #include <klic/g_methtab.h>
 
 /* runtime/generic.c */
@@ -37,11 +38,8 @@
 
 #define isgobj(x)  (isref(functor_of(x)))
 
-#ifdef __STDC__
-#define data_object_method_table_of(class) class##_g_data_method_table
-#else
-#define data_object_method_table_of(class) class/**/_g_data_method_table
-#endif
+#define data_object_method_table_of(class) \
+  CONCATENATE(class, _g_data_method_table)
 
 #define isclass(x, class) \
   ((struct data_object_method_table *)(functor_of(x)) == \
diff -ruN klic-3.003-2001-12-30/include/klic/gg_macro.h klic-3.003-2001-12-31/include/klic/gg_macro.h
--- klic-3.003-2001-12-30/include/klic/gg_macro.h	Sat Dec 29 12:46:20 2001
+++ klic-3.003-2001-12-31/include/klic/gg_macro.h	Mon Dec 31 12:04:47 2001
@@ -8,6 +8,7 @@
 #ifndef _KLIC_GG_MACRO_H_
 #define _KLIC_GG_MACRO_H_
 
+#include <klic/stdc.h>  /* CONCATENATE */
 #include <klic/basic.h>  /* fatal, klic_fprintf */
 
 extern q GC_wakeup_g_new();
@@ -32,24 +33,14 @@
 
 #define GG_OBJ_SIZE G_SIZE_IN_Q(GG_OBJ_TYPE)
 
-#ifdef __STDC__
-#define GG_method_table1(class) class##_g_generator_method_table
-#else
-#define GG_method_table1(class) class/**/_g_generator_method_table
-#endif
-
-#define GG_method_table0(class) GG_method_table1(class)
+#define GG_method_table0(class)  CONCATENATE(class, _g_generator_method_table)
 
 #define GG_method_table GG_method_table0(GG_CLASS_NAME())
 
 #define GG_USE_CLASS(class) \
 extern struct generator_object_method_table GG_method_table0(class)
 
-#ifdef __STDC__
 #define GG_CLASS_NAME_STRING G_stringify(GG_CLASS_NAME())
-#else
-#define GG_CLASS_NAME_STRING 0
-#endif
 
 #define GG_FAIL(errmsg) fatal(errmsg)
 #define GG_ERROR_IN_NEW(errmsg) \
diff -ruN klic-3.003-2001-12-30/include/klic/stdc.h klic-3.003-2001-12-31/include/klic/stdc.h
--- klic-3.003-2001-12-30/include/klic/stdc.h	Thu Jan  1 09:00:00 1970
+++ klic-3.003-2001-12-31/include/klic/stdc.h	Mon Dec 31 12:07:56 2001
@@ -0,0 +1,34 @@
+/* -------------------------------------------------------------
+% Copyright 2001, TAKAGI Yusuke
+%   (Read COPYRIGHT for detailed information.)
+------------------------------------------------------------- */
+
+#ifndef _KLIC_STDC_H_
+#define _KLIC_STDC_H_
+
+/* for compatibility with non-standard C */
+
+#ifdef __STDC__
+#define CONCATENATE(x,y)     x ## y
+#define CONCATENATE_3(x,y,z) x ## y ## z
+#define STRINGIFY(s)         # s
+
+#define USE_STDARG
+#include <stdarg.h>
+#define VA_START(A, L)	va_start(A, L)
+#define VA_ARGS(A)	A
+
+#else  /* !__STDC__ */
+#define const
+#define volatile
+
+#define CONCATENATE(x,y)     x/**/y
+#define CONCATENATE_3(x,y,z) x/**/y/**/z
+#define STRINGIFY(s)         "s"
+
+#include <varargs.h>
+#define VA_START(A, L)	va_start(A)
+#define VA_ARGS(A)	()
+#endif  /* !__STDC__ */
+
+#endif  /* _KLIC_STDC_H_ */
diff -ruN klic-3.003-2001-12-30/runtime/Makefile.tail klic-3.003-2001-12-31/runtime/Makefile.tail
--- klic-3.003-2001-12-30/runtime/Makefile.tail	Sun Dec 30 17:14:44 2001
+++ klic-3.003-2001-12-31/runtime/Makefile.tail	Mon Dec 31 12:04:47 2001
@@ -20,7 +20,7 @@
 	$(COMPILEINC)/primitives.h $(COMPILEINC)/schedule.h \
 	$(COMPILEINC)/susp.h $(COMPILEINC)/struct.h \
 	$(COMPILEINC)/timing.h $(COMPILEINC)/unify.h \
-	$(COMPILEINC)/trace.h \
+	$(COMPILEINC)/trace.h $(COMPILEINC)/stdc.h \
 	$(COMPILEINC)/g_basic.h $(COMPILEINC)/g_extern.h \
 	$(COMPILEINC)/gd_macro.h \
 	$(COMPILEINC)/gd_methtab.h $(COMPILEINC)/gdobject.h \
diff -ruN klic-3.003-2001-12-30/runtime/config/pvm/distio.h klic-3.003-2001-12-31/runtime/config/pvm/distio.h
--- klic-3.003-2001-12-30/runtime/config/pvm/distio.h	Thu Dec 27 19:15:57 2001
+++ klic-3.003-2001-12-31/runtime/config/pvm/distio.h	Mon Dec 31 12:04:47 2001
@@ -6,16 +6,8 @@
 ----------------------------------------------------------- */
 /* PVM dependent I/O communication library */
 /* $Id: distio.h,v 1.1.1.1 2000/07/28 02:01:42 igarashi Exp $ */
-#ifdef __STDC__
-#define USE_STDARG
-#include <stdarg.h>
-#define VA_START(A, L)	va_start(A, L)
-#define VA_ARGS(A)	A
-#else
-#include <varargs.h>
-#define VA_START(A, L)	va_start(A)
-#define VA_ARGS(A)	()
-#endif
+
+#include <klic/stdc.h>  /* VA_ARGS */
 
 enum io_tag {
     FinishTag,
diff -ruN klic-3.003-2001-12-30/runtime/config/shm/distio.h klic-3.003-2001-12-31/runtime/config/shm/distio.h
--- klic-3.003-2001-12-30/runtime/config/shm/distio.h	Thu Dec 27 19:15:57 2001
+++ klic-3.003-2001-12-31/runtime/config/shm/distio.h	Mon Dec 31 12:04:47 2001
@@ -7,17 +7,7 @@
 #ifndef _KLIC_DISTIO_H_
 #define _KLIC_DISTIO_H_
 
-#ifdef __STDC__
-#define USE_STDARG
-#include <stdarg.h>
-#define VA_START(A, L)	va_start(A, L)
-#define VA_ARGS(A)	A
-#else
-#include <varargs.h>
-#define VA_START(A, L)	va_start(A)
-#define VA_ARGS(A)	()
-#endif
-
+#include <klic/stdc.h>  /* VA_ARGS */
 #include <klic/distpkt.h>
 
 enum io_tag {
diff -ruN klic-3.003-2001-12-30/runtime/debug.c klic-3.003-2001-12-31/runtime/debug.c
--- klic-3.003-2001-12-30/runtime/debug.c	Sat Dec 29 12:46:20 2001
+++ klic-3.003-2001-12-31/runtime/debug.c	Mon Dec 31 12:04:47 2001
@@ -11,7 +11,7 @@
 #include <string.h>
 
 /* fatal, fatalf, fatalp, debug_printf, debug_fprintf, klic_fprintf,
- * klic_putc
+ * klic_putc, VA_ARGS
  */
 #include <klic/basic.h>
 
@@ -249,11 +249,7 @@
 #endif  /* DIST */
 
 #ifdef DECL_FPRINTF
-#ifdef __STDC__
-extern int fprintf(FILE *out, char *format, ...);
-#else
-extern int fprintf();
-#endif
+extern int fprintf VA_ARGS((FILE *out, char *format, ...));
 #endif
 
 static Inline void 
@@ -271,11 +267,7 @@
   declare_globals;
 #endif
 
-#ifdef __STDC__ 
-  void (*fprintf_func)(FILE *out, char *format, ...);
-#else
-  void (*fprintf_func)();
-#endif
+  void (*fprintf_func) VA_ARGS((FILE *out, char *format, ...));
 
   long args[12], *argp;
   args[0] = a0; args[1] = a1; args[2] = a2; args[3] = a3;
@@ -286,16 +278,11 @@
 #ifdef DIST
   if(redirect) {
     fprintf_func = iofprintf;
-  } else {
+  } else
 #endif
-#ifdef __STDC__
-    fprintf_func = (void (*)(FILE *, char *, ...))(fprintf);
-#else
-    fprintf_func = (void (*)())(fprintf);
-#endif
-#ifdef DIST
+  {
+    fprintf_func = (void (*) VA_ARGS((FILE *, char *, ...))) (fprintf);
   }
-#endif
 
   for (f = format; *f != '\0'; f++) {
     if (*f == '%') {
diff -ruN klic-3.003-2001-12-30/runtime/faisus.c klic-3.003-2001-12-31/runtime/faisus.c
--- klic-3.003-2001-12-30/runtime/faisus.c	Sat Dec 29 12:46:20 2001
+++ klic-3.003-2001-12-31/runtime/faisus.c	Mon Dec 31 12:04:47 2001
@@ -149,9 +149,9 @@
 
 extern q*
 interrupt_goal(allocp, pred, reasonp)
-     q *allocp;
-     struct predicate *pred;
-     q *reasonp;
+  q* allocp;
+  const struct predicate* pred;
+  q* reasonp;
 {
   declare_globals;
   struct goalrec *goal = (struct goalrec *)allocp;
diff -ruN klic-3.003-2001-12-30/runtime/gcode.c klic-3.003-2001-12-31/runtime/gcode.c
--- klic-3.003-2001-12-30/runtime/gcode.c	Sat Dec 29 12:46:20 2001
+++ klic-3.003-2001-12-31/runtime/gcode.c	Mon Dec 31 12:08:39 2001
@@ -268,7 +268,7 @@
   GD_DEREF_FOR_NEW(GD_ARGV[0]);
   if(!G_ISFUNCTOR(GD_ARGV[0]) ||
      (((struct module_object *)(G_FUNCTORP(GD_ARGV[0])))->method_table
-      != &(GD_method_table1(module)))) {
+      != &(GD_method_table0(module)))) {
     GD_ERROR_IN_NEW("First parameter is not a module");
   }
   module_obj = (struct module_object *)(G_FUNCTORP(GD_ARGV[0]));
diff -ruN klic-3.003-2001-12-30/runtime/xio.c klic-3.003-2001-12-31/runtime/xio.c
--- klic-3.003-2001-12-30/runtime/xio.c	Sat Dec 29 12:46:20 2001
+++ klic-3.003-2001-12-31/runtime/xio.c	Mon Dec 31 12:04:47 2001
@@ -22,8 +22,9 @@
 #include <klic/distio.h>
 #endif
 
-Inline int debug_getc(f)
-     FILE *f;
+static Inline int
+debug_getc(f)
+  FILE* f;
 {
   while (1) {
     int result = getc(f);
@@ -33,44 +34,33 @@
   }
 }
 
-Inline int debug_fread(pt, size, items, f)
-     void *pt;
-     size_t size, items;
-     FILE *f;
+static Inline int
+debug_fread(pt, size, items, f)
+  void* pt;
+  size_t size, items;
+  FILE* f;
 {
   return fread(pt, size, items, f);
 }
 
-char *debug_fgets(buf, length, f)
-     char *buf;
-     size_t length;
-     FILE *f;
+static char*
+debug_fgets(buf, length, f)
+  char* buf;
+  size_t length;
+  FILE* f;
 {
   while (1) {
-    char *result = fgets(buf, length, f);
+    char* result = fgets(buf, length, f);
     if (result!=NULL || feof(f) || errno != EINTR) {
       return result;
     }
   }
 }
 
-#if 0
-extern int debug_putc(c, f)
-     int c;
-     FILE *f;
-{
-  while (1) {
-    int result = putc(c, f);
-    if (result!=EOF || feof(f) || errno != EINTR) {
-      return result;
-    }
-  }
-}
-#endif
-
-Inline int debug_fputc(c, f)
-int c;
-FILE *f;
+extern Inline int
+debug_fputc(c, f)
+  int c;
+  FILE* f;
 {
   while(1) {
     int result = fputc(c, f);
@@ -80,16 +70,18 @@
   }
 }
 
-Inline int debug_fwrite(pt, size, items, f)
-     const void* pt;
-     size_t size, items;
-     FILE *f;
+extern Inline int
+debug_fwrite(pt, size, items, f)
+  const void* pt;
+  size_t size, items;
+  FILE* f;
 {
   return fwrite(pt, size, items, f);
 }
 
-Inline int debug_fflush(f)
-     FILE *f;
+extern Inline int
+debug_fflush(f)
+  FILE* f;
 {
   while (1) {
     int result = fflush(f);
@@ -105,7 +97,7 @@
 
 extern int
 klic_getc(f)
-FILE *f;
+  FILE* f;
 {
 #ifdef DIST
   if(f == stdin) {
@@ -117,10 +109,10 @@
 
 extern int
 klic_fread(pt, size, items, f)
-     void *pt;
-     size_t size;
-     size_t items;
-     FILE *f;
+  void* pt;
+  size_t size;
+  size_t items;
+  FILE* f;
 {
 #ifdef DIST
   /*
@@ -133,23 +125,25 @@
   return debug_fread(pt, size, items, f);
 }
 
-char *klic_fgets(buf, len, f)
-     char *buf;
-     size_t len;
-     FILE *f;
+extern char*
+klic_fgets(buf, len, f)
+  char* buf;
+  size_t len;
+  FILE* f;
 {
 #ifdef DIST
-  if(f == stdin)
+  if(f == stdin){
     SystemRead(buf);
     return buf;
+  }
 #endif
   return debug_fgets(buf, len, f);
 }
 
 extern int
 klic_putc(c, out)
-int c;
-FILE *out;
+  int c;
+  FILE* out;
 {
 #ifdef DIST
   if(out == stdout)
@@ -162,9 +156,9 @@
 
 extern int
 klic_fwrite(pt, size, items, f)
-     const void* pt;
-     size_t size, items;
-     FILE *f;
+  const void* pt;
+  size_t size, items;
+  FILE* f;
 {
 #ifdef DIST
   if(f == stdout)
@@ -177,7 +171,7 @@
 
 extern int
 klic_fflush(f)
-     FILE *f;
+  FILE* f;
 {
 #ifdef DIST
   if(f == stdout)
@@ -187,4 +181,3 @@
 #endif
   return debug_fflush(f);
 }
-
