r18754 - gnucash/trunk/src/engine - MSVC compatiblity: Struct initialization doesn't work as expected.

Christian Stimming cstim at code.gnucash.org
Sat Feb 27 13:41:28 EST 2010


Author: cstim
Date: 2010-02-27 13:41:28 -0500 (Sat, 27 Feb 2010)
New Revision: 18754
Trac: http://svn.gnucash.org/trac/changeset/18754

Modified:
   gnucash/trunk/src/engine/Account.c
Log:
MSVC compatiblity: Struct initialization doesn't work as expected.

Somehow, the struct initialization containing a gnc_numeric
doesn't work. As an exception, we hand-initialize that member
afterwards.

Modified: gnucash/trunk/src/engine/Account.c
===================================================================
--- gnucash/trunk/src/engine/Account.c	2010-02-27 18:41:07 UTC (rev 18753)
+++ gnucash/trunk/src/engine/Account.c	2010-02-27 18:41:28 UTC (rev 18754)
@@ -3311,7 +3311,15 @@
   /* If needed, sum up the children converting to the *requested*
      commodity. */
   if (include_children) {
+#ifdef _MSC_VER
+    /* MSVC compiler: Somehow, the struct initialization containing a
+       gnc_numeric doesn't work. As an exception, we hand-initialize
+       that member afterwards. */
+    CurrencyBalance cb = { report_commodity, { 0 }, fn, NULL, 0 };
+    cb.balance = balance;
+#else
     CurrencyBalance cb = { report_commodity, balance, fn, NULL, 0 };
+#endif
 
     gnc_account_foreach_descendant (acc, xaccAccountBalanceHelper, &cb);
     balance = cb.balance;
@@ -3339,7 +3347,15 @@
   /* If needed, sum up the children converting to the *requested*
      commodity. */
   if (include_children) {
+#ifdef _MSC_VER
+    /* MSVC compiler: Somehow, the struct initialization containing a
+       gnc_numeric doesn't work. As an exception, we hand-initialize
+       that member afterwards. */
+    CurrencyBalance cb = { report_commodity, 0, NULL, fn, date };
+    cb.balance = balance;
+#else
     CurrencyBalance cb = { report_commodity, balance, NULL, fn, date };
+#endif
 
     gnc_account_foreach_descendant (acc, xaccAccountBalanceAsOfDateHelper, &cb);
     balance = cb.balance;



More information about the gnucash-changes mailing list