Fix fakegen.rb C header generator for M macro compatibility.
diff --git a/fakegen.rb b/fakegen.rb
index 3cfdbee..59d4ea2 100644
--- a/fakegen.rb
+++ b/fakegen.rb
@@ -31,7 +31,7 @@
 # ------  Helper macros to use internally ------ #
 def output_internal_helper_macros
   putd "/* -- INTERNAL HELPER MACROS -- */"
-  
+
   define_return_sequence_helper
   define_custom_fake_sequence_helper
   define_reset_fake_macro
@@ -47,7 +47,7 @@
   define_return_fake_result_helper
   define_extern_c_helper
   define_reset_fake_helper
-  
+
   putd "/* -- END INTERNAL HELPER MACROS -- */"
   putd ""
 end
@@ -115,9 +115,9 @@
 def define_value_function_variables_helper
   putd ""
   putd "#define DECLARE_VALUE_FUNCTION_VARIABLES(RETURN_TYPE) \\"
-  putd "    RETURN_TYPE return_val; \\" 
-  putd "    int return_val_seq_len; \\" 
-  putd "    int return_val_seq_idx; \\" 
+  putd "    RETURN_TYPE return_val; \\"
+  putd "    int return_val_seq_len; \\"
+  putd "    int return_val_seq_idx; \\"
   putd "    RETURN_TYPE * return_val_seq; \\"
 end
 
@@ -149,8 +149,8 @@
 def define_extern_c_helper
   putd ""
   putd "#ifdef __cplusplus"
-  putd "    #define FFF_EXTERN_C extern \"C\"{" 
-  putd "    #define FFF_END_EXTERN_C } " 
+  putd "    #define FFF_EXTERN_C extern \"C\"{"
+  putd "    #define FFF_END_EXTERN_C } "
   putd "#else  /* ansi c */"
   putd "    #define FFF_EXTERN_C "
   putd "    #define FFF_END_EXTERN_C "
@@ -198,7 +198,7 @@
       output_variables(saved_arg_count, has_varargs, is_value_function)
     }
   popd
-  
+
   putd ""
   output_macro_header(define_macro_name, saved_arg_count, has_varargs, return_type)
   pushd
@@ -212,9 +212,9 @@
       putd "DEFINE_RESET_FUNCTION(FUNCNAME) \\"
     }
   popd
-  
+
   putd ""
-  
+
   output_macro_header(fake_macro_name, saved_arg_count, has_varargs, return_type)
   pushd
     putd macro_signature_for(declare_macro_name, saved_arg_count, has_varargs, return_type)
@@ -246,7 +246,7 @@
   parameter_list += ", ..." if has_varargs
 
   parameter_list +=  ") \\"
-  
+
   parameter_list
 end
 
@@ -256,7 +256,7 @@
 
 def output_variables(arg_count, has_varargs, is_value_function)
   in_struct{
-    arg_count.times { |argN| 
+    arg_count.times { |argN|
       putd "DECLARE_ARG(ARG#{argN}_TYPE, #{argN}, FUNCNAME) \\"
     }
     putd "DECLARE_ALL_FUNC_COMMON \\"
@@ -380,7 +380,7 @@
 
 def extern_c
   putd "FFF_EXTERN_C \\"
-  pushd 
+  pushd
     yield
   popd
   putd "FFF_END_EXTERN_C \\"
@@ -405,7 +405,12 @@
   putd "#endif /* FAKE_FUNCTIONS */"
 end
 
-def generate_arg_sequence(args, prefix, do_reverse, joinstr) 
+def msvc_expand_macro_fix
+    putd "/* MSVC expand macro fix */"
+    putd "#define EXPAND(x) x"
+end
+
+def generate_arg_sequence(args, prefix, do_reverse, joinstr)
  fmap = (0..args).flat_map {|i| [prefix + i.to_s]}
  if do_reverse then fmap.reverse.join(joinstr) else fmap.join(", ") end
 end
@@ -416,25 +421,26 @@
 
   <<-MACRO_COUNTING_INSTANCE
 #define #{prefix}FAKE_#{type.to_s}_FUNC#{appendix}(...) \
-    #{prefix}FUNC_#{type.to_s}#{appendix}_(PP_NARG_MINUS#{minus_count}(__VA_ARGS__), __VA_ARGS__)
+    EXPAND(#{prefix}FUNC_#{type.to_s}#{appendix}_(PP_NARG_MINUS#{minus_count}(__VA_ARGS__), __VA_ARGS__))
 
 #define #{prefix}FUNC_#{type.to_s}#{appendix}_(N,...) \
-    #{prefix}FUNC_#{type.to_s}#{appendix}_N(N,__VA_ARGS__)
+    EXPAND(#{prefix}FUNC_#{type.to_s}#{appendix}_N(N,__VA_ARGS__))
 
 #define #{prefix}FUNC_#{type.to_s}#{appendix}_N(N,...) \
-    #{prefix}FAKE_#{type.to_s}_FUNC ## N#{" ## _VARARG" if vararg == :vararg}(__VA_ARGS__)
+    EXPAND(#{prefix}FAKE_#{type.to_s}_FUNC ## N#{" ## _VARARG" if vararg == :vararg}(__VA_ARGS__))
 
   MACRO_COUNTING_INSTANCE
 end
 
 def output_macro_counting_shortcuts
+  msvc_expand_macro_fix
   putd <<-MACRO_COUNTING
 
 #define PP_NARG_MINUS2(...) \
-    PP_NARG_MINUS2_(__VA_ARGS__, PP_RSEQ_N_MINUS2())
+    EXPAND(PP_NARG_MINUS2_(__VA_ARGS__, PP_RSEQ_N_MINUS2()))
 
 #define PP_NARG_MINUS2_(...) \
-    PP_ARG_MINUS2_N(__VA_ARGS__)
+    EXPAND(PP_ARG_MINUS2_N(__VA_ARGS__))
 
 #define PP_ARG_MINUS2_N(returnVal, #{generate_arg_sequence($MAX_ARGS, '_', false, ", ")}, N, ...)   N
 
@@ -443,10 +449,10 @@
 
 
 #define PP_NARG_MINUS1(...) \
-    PP_NARG_MINUS1_(__VA_ARGS__, PP_RSEQ_N_MINUS1())
+    EXPAND(PP_NARG_MINUS1_(__VA_ARGS__, PP_RSEQ_N_MINUS1()))
 
 #define PP_NARG_MINUS1_(...) \
-    PP_ARG_MINUS1_N(__VA_ARGS__)
+    EXPAND(PP_ARG_MINUS1_N(__VA_ARGS__))
 
 #define PP_ARG_MINUS1_N(#{generate_arg_sequence($MAX_ARGS, '_', false, ", ")}, N, ...)   N