C++ Windows fixes.

Particularly interesting is src/engine/Makefile.am: Having a mention of
target_CFLAGS in an #if disables automatic use AM_CFLAGS even when the
#if condition is false.
This commit is contained in:
John Ralls 2014-04-27 12:53:21 -07:00
parent c7f4bf7fed
commit 82df074771
9 changed files with 25 additions and 51 deletions

View File

@ -131,6 +131,8 @@ noinst_SCRIPTS = iso-currencies-to-c
libgncmod_engine_la_LDFLAGS = -avoid-version
if CLANG
libgncmod_engine_la_CFLAGS = ${AM_CFLAGS} -Wno-invalid-source-encoding
else
libgncmod_engine_la_CFLAGS = ${AM_CFLAGS}
endif
libgncmod_engine_la_LIBADD = \
../gnc-module/libgnc-module.la \

View File

@ -126,7 +126,8 @@ test_engine_CFLAGS = \
${DEFAULT_INCLUDES} \
-I${top_srcdir}/${MODULEPATH}/ \
-DTESTPROG=test_engine \
${GLIB_CFLAGS}
${GLIB_CFLAGS} \
${AM_CFLAGS}
noinst_LTLIBRARIES = \
libutest-Split.la \

View File

@ -119,7 +119,6 @@ gnc_g_time_zone_new_local (void)
#else
{
TIME_ZONE_INFORMATION tzinfo;
gint64 dst = GetTimeZoneInformation (&tzinfo);
gint bias = tzinfo.Bias + tzinfo.StandardBias;
gint hours = -bias / 60; // 60 minutes per hour
gint minutes = (bias < 0 ? -bias : bias) % 60;
@ -151,13 +150,13 @@ dst_systemtime_to_gdate (SYSTEMTIME stime, GDate *gdate, gint year)
*/
static const int gdate_sunday = 7;
static const int week_length = 7;
GDateMonth month = static_cast<GDateMonth>(stime.wMonth);
g_date_clear (gdate, 1);
g_date_set_dmy (gdate, 1, stime.wMonth, year);
g_date_set_dmy (gdate, 1, month, year);
wkday = g_date_get_weekday (gdate) % gdate_sunday;
days = week_length * stime.wDay + stime.wDayOfWeek - wkday;
while (days > g_date_get_days_in_month (stime.wMonth, year))
while (days > g_date_get_days_in_month (month, year))
days -= week_length;
g_date_add_days (gdate, days);
wkday = g_date_get_weekday (gdate) % gdate_sunday;
@ -179,7 +178,7 @@ win32_in_dst (GDateTime *date, TIME_ZONE_INFORMATION *tzinfo)
return FALSE;
g_date_time_get_ymd (date, &year, &month, &day);
g_date_clear (&gdate, 1);
g_date_set_dmy (&gdate, day, month, year);
g_date_set_dmy (&gdate, day, static_cast<GDateMonth>(month), year);
dst_systemtime_to_gdate (tzinfo->StandardDate, &std, year);
dst_systemtime_to_gdate (tzinfo->DaylightDate, &dlt, year);
/* In the southern hemisphere, where DST ends in spring and begins in fall, we look for the date being before std or after dlt; in the northern hemisphere we look for them to be between dlt and std.

View File

@ -676,10 +676,10 @@ guid_to_string(const GncGUID * guid)
static GStaticPrivate guid_buffer_key = G_STATIC_PRIVATE_INIT;
gchar *string;
string = g_static_private_get (&guid_buffer_key);
string = static_cast<gchar*>(g_static_private_get (&guid_buffer_key));
if (string == NULL)
{
string = malloc(GUID_ENCODING_LENGTH + 1);
string = static_cast<gchar*>(malloc(GUID_ENCODING_LENGTH + 1));
g_static_private_set (&guid_buffer_key, string, g_free);
}
#else

View File

@ -44,11 +44,12 @@ G_LOCK_DEFINE_STATIC(picture_to_format);
gchar *
qof_time_format_from_utf8(const gchar *utf8_format)
{
gunichar2 *utf16_format;
gchar *retval;
wchar_t* utf16_format;
gchar* retval;
gsize count;
utf16_format = g_utf8_to_utf16(utf8_format, -1, NULL, NULL, NULL);
utf16_format = reinterpret_cast<wchar_t*>(g_utf8_to_utf16(utf8_format, -1,
NULL, NULL, NULL));
if (!utf16_format)
return NULL;
@ -58,7 +59,7 @@ qof_time_format_from_utf8(const gchar *utf8_format)
return NULL;
/* malloc and convert */
retval = g_malloc((count + 1) * sizeof(gchar));
retval = static_cast<gchar*>(g_malloc((count + 1) * sizeof(gchar)));
count = wcstombs(retval, utf16_format, count + 1);
g_free(utf16_format);
if (count <= 0)
@ -83,8 +84,9 @@ qof_formatted_time_to_utf8(const gchar *locale_string)
return NULL;
/* malloc and convert */
utf16_string = g_malloc((count + 1) * sizeof(gunichar2));
count = mbstowcs(utf16_string, locale_string, count + 1);
utf16_string = static_cast<gunichar2*>(g_malloc((count + 1) * sizeof(gunichar2)));
count = mbstowcs(reinterpret_cast<wchar_t*>(utf16_string),
locale_string, count + 1);
if (count <= 0)
{
g_free(utf16_string);
@ -125,8 +127,8 @@ qof_win32_get_time_format(QofWin32Picture picture)
G_LOCK(picture_to_format);
if (!picture_to_format)
picture_to_format = g_hash_table_new_full(g_str_hash, g_str_equal,
NULL, g_free);
format = g_hash_table_lookup(picture_to_format, locale_string);
NULL, g_free);
format = static_cast<char*>(g_hash_table_lookup(picture_to_format, locale_string));
if (!format)
{
format = translate_win32_picture(locale_string);

View File

@ -197,7 +197,7 @@ div128 (qofint128 n, gint64 d)
remainder <<= 1;
if (sbit) remainder |= 1;
quotient = shiftleft128 (quotient);
if (remainder >= static_cast<unsigned int64_t>(d))
if (remainder >= static_cast<guint64>(d))
{
remainder -= d;
quotient.lo |= 1;

View File

@ -995,7 +995,7 @@ qof_print_date_buff (char * buff, size_t len, time64 t)// C: 3 in 1 Local: 2:0:
static void
test_qof_print_date_buff (void)
{
gchar buff[MAX_DATE_LENGTH], t_buff[MAX_DATE_LENGTH];
gchar buff[MAX_DATE_LENGTH];
gchar *locale = g_strdup (setlocale (LC_TIME, NULL));
GDateTime *gd1 = gncdt.new_local (1974, 11, 23, 12, 0, 0.0);
GDateTime *gd2 = gncdt.new_local (1961, 2, 2, 12, 0, 0.0);
@ -1276,7 +1276,6 @@ static void
test_qof_print_date (void)
{
gchar *locale = g_strdup (setlocale (LC_TIME, NULL));
gchar *buff;
GDateTime *gd1 = gncdt.new_local (1974, 11, 23, 12, 0, 0.0);
GDateTime *gd2 = gncdt.new_local (1961, 2, 2, 12, 0, 0.0);
GDateTime *gd3 = gncdt.new_local (2045, 6, 16, 12, 0, 0.0);

View File

@ -446,42 +446,12 @@ mock_sync (QofBackend *be, QofBook *book)
session_save_struct.sync_called = TRUE;
}
static void
mock_session_begin_for_save (QofBackend *be, QofSession *session, const char *book_id,
gboolean ignore_lock, gboolean create, gboolean force)
{
g_assert (be);
g_assert (be == session_save_struct.be);
g_assert (session);
g_assert (session == session_save_struct.session);
g_assert (book_id);
g_assert_cmpstr (book_id, == , session_save_struct.book_id);
g_assert (ignore_lock);
g_assert (create);
g_assert (force);
session_save_struct.session_begin_called = TRUE;
}
static QofBackend*
mock_backend_new_for_save (void)
{
QofBackend *be = NULL;
be = g_new0 (QofBackend, 1);
g_assert (be);
be->session_begin = mock_session_begin_for_save;
be->sync = mock_sync;
session_save_struct.be = be;
session_save_struct.backend_new_called = TRUE;
return be;
}
static void
test_qof_session_save (Fixture *fixture, gconstpointer pData)
{
QofBook *book = NULL;
QofBackend *be = NULL;
QofBackendProvider *prov = NULL, *reg_prov = NULL;
QofBackendProvider *prov = NULL;
g_test_message ("Test when backend not set");
g_assert (fixture->session->backend == NULL);

View File

@ -52,7 +52,8 @@ libtest_core_guile_la_LIBADD = \
libtest_core_guile_la_CFLAGS = \
${libtest_core_la_CPPFLAGS} \
${GUILE_CFLAGS}
${GUILE_CFLAGS} \
${AM_CFLAGS}
libtest_core_guile_la_LDFLAGS = \
-rpath ${exec-prefix}/lib