r18750 - gnucash/trunk/src - MSVC compatiblity: Array initialization in MSVC requires a constant, not a variable.

Christian Stimming cstim at code.gnucash.org
Sat Feb 27 13:40:00 EST 2010


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

Modified:
   gnucash/trunk/src/backend/xml/gnc-backend-xml.c
   gnucash/trunk/src/engine/Recurrence.c
Log:
MSVC compatiblity: Array initialization in MSVC requires a constant, not a variable.

That is, gcc accepts a constant variable in many cases now, but
MSVC doesn't accept it. So it must be turned into an old preprocessor
define.

Modified: gnucash/trunk/src/backend/xml/gnc-backend-xml.c
===================================================================
--- gnucash/trunk/src/backend/xml/gnc-backend-xml.c	2010-02-27 18:39:39 UTC (rev 18749)
+++ gnucash/trunk/src/backend/xml/gnc-backend-xml.c	2010-02-27 18:40:00 UTC (rev 18750)
@@ -363,10 +363,12 @@
    "file.YYYYMMDDHHMMSS.xac" where YYYYMMDDHHMMSS is replaced with the
    current year/month/day/hour/minute/second. */
 
+/* The variable buf_size must be a compile-time constant */
+#define buf_size 1024
+
 static gboolean
 copy_file(const char *orig, const char *bkup)
 {
-    static int buf_size = 1024;
     char buf[buf_size];
     int orig_fd;
     int bkup_fd;

Modified: gnucash/trunk/src/engine/Recurrence.c
===================================================================
--- gnucash/trunk/src/engine/Recurrence.c	2010-02-27 18:39:39 UTC (rev 18749)
+++ gnucash/trunk/src/engine/Recurrence.c	2010-02-27 18:40:00 UTC (rev 18750)
@@ -555,13 +555,14 @@
     }
 }
 
+/* A constant is needed for the array size */
+#define abbrev_day_name_bufsize 10
 static void
 _monthly_append_when(Recurrence *r, GString *buf)
 {
     GDate date = recurrenceGetDate(r);
     if (recurrenceGetPeriodType(r) == PERIOD_LAST_WEEKDAY)
     {
-        gint abbrev_day_name_bufsize = 10;
         gchar day_name_buf[abbrev_day_name_bufsize];
 
         gnc_dow_abbrev(day_name_buf, abbrev_day_name_bufsize, g_date_get_weekday(&date) % 7);



More information about the gnucash-changes mailing list