From 9e10cec7d7051b56ce10f0c801f53f7c3e5a2b04 Mon Sep 17 00:00:00 2001 From: jfali Date: Tue, 8 Sep 2015 14:25:06 +0200 Subject: [PATCH] Fixing compilation problems with Microsoft Visual Studio 2008. - inttypes.h is not available in MSVC 2008 - Structs members must be initialized implicitly --- ext/extconf.rb | 1 + ext/pg_binary_decoder.c | 2 ++ ext/pg_binary_encoder.c | 2 ++ ext/pg_text_decoder.c | 2 ++ ext/pg_text_encoder.c | 2 ++ ext/pg_type_map.c | 12 ++++++------ ext/pg_type_map_by_column.c | 12 ++++++------ 7 files changed, 21 insertions(+), 12 deletions(-) diff --git a/ext/extconf.rb b/ext/extconf.rb index 7e5727ba1..f8e709553 100644 --- a/ext/extconf.rb +++ b/ext/extconf.rb @@ -92,6 +92,7 @@ # unistd.h confilicts with ruby/win32.h when cross compiling for win32 and ruby 1.9.1 have_header 'unistd.h' +have_header 'inttypes.h' have_header 'ruby/st.h' or have_header 'st.h' or abort "pg currently requires the ruby/st.h header" checking_for "C99 variable length arrays" do diff --git a/ext/pg_binary_decoder.c b/ext/pg_binary_decoder.c index 18e8295d6..a00e7a8bd 100644 --- a/ext/pg_binary_decoder.c +++ b/ext/pg_binary_decoder.c @@ -6,7 +6,9 @@ #include "pg.h" #include "util.h" +#ifdef HAVE_INTTYPES_H #include +#endif VALUE rb_mPG_BinaryDecoder; diff --git a/ext/pg_binary_encoder.c b/ext/pg_binary_encoder.c index 76cd984a2..27cec533e 100644 --- a/ext/pg_binary_encoder.c +++ b/ext/pg_binary_encoder.c @@ -6,7 +6,9 @@ #include "pg.h" #include "util.h" +#ifdef HAVE_INTTYPES_H #include +#endif VALUE rb_mPG_BinaryEncoder; diff --git a/ext/pg_text_decoder.c b/ext/pg_text_decoder.c index 66be3767e..a0575bc51 100644 --- a/ext/pg_text_decoder.c +++ b/ext/pg_text_decoder.c @@ -30,7 +30,9 @@ #include "pg.h" #include "util.h" +#ifdef HAVE_INTTYPES_H #include +#endif VALUE rb_mPG_TextDecoder; static ID s_id_decode; diff --git a/ext/pg_text_encoder.c b/ext/pg_text_encoder.c index b373b5570..9f3f27634 100644 --- a/ext/pg_text_encoder.c +++ b/ext/pg_text_encoder.c @@ -41,7 +41,9 @@ #include "pg.h" #include "util.h" +#ifdef HAVE_INTTYPES_H #include +#endif #include VALUE rb_mPG_TextEncoder; diff --git a/ext/pg_type_map.c b/ext/pg_type_map.c index 9c105169b..a0a94d3e3 100644 --- a/ext/pg_type_map.c +++ b/ext/pg_type_map.c @@ -54,12 +54,12 @@ pg_typemap_typecast_copy_get( t_typemap *p_typemap, VALUE field_str, int fieldno } const struct pg_typemap_funcs pg_typemap_funcs = { - .fit_to_result = pg_typemap_fit_to_result, - .fit_to_query = pg_typemap_fit_to_query, - .fit_to_copy_get = pg_typemap_fit_to_copy_get, - .typecast_result_value = pg_typemap_result_value, - .typecast_query_param = pg_typemap_typecast_query_param, - .typecast_copy_get = pg_typemap_typecast_copy_get + pg_typemap_fit_to_result, + pg_typemap_fit_to_query, + pg_typemap_fit_to_copy_get, + pg_typemap_result_value, + pg_typemap_typecast_query_param, + pg_typemap_typecast_copy_get }; static VALUE diff --git a/ext/pg_type_map_by_column.c b/ext/pg_type_map_by_column.c index 41bce5316..661dc3f16 100644 --- a/ext/pg_type_map_by_column.c +++ b/ext/pg_type_map_by_column.c @@ -162,12 +162,12 @@ pg_tmbc_typecast_copy_get( t_typemap *p_typemap, VALUE field_str, int fieldno, i } const struct pg_typemap_funcs pg_tmbc_funcs = { - .fit_to_result = pg_tmbc_fit_to_result, - .fit_to_query = pg_tmbc_fit_to_query, - .fit_to_copy_get = pg_tmbc_fit_to_copy_get, - .typecast_result_value = pg_tmbc_result_value, - .typecast_query_param = pg_tmbc_typecast_query_param, - .typecast_copy_get = pg_tmbc_typecast_copy_get + pg_tmbc_fit_to_result, + pg_tmbc_fit_to_query, + pg_tmbc_fit_to_copy_get, + pg_tmbc_result_value, + pg_tmbc_typecast_query_param, + pg_tmbc_typecast_copy_get }; static void