MSVC compatibility: Microsoft doesn't have C99 "designated initializers".

Those were introduced in r17724, bug#539957, but apparently this
C99 is not supported by MSVC and won't be for some time to come.
Hence, for MSVC we need the workaround to define a macro that will
shadow the member names. However, the initialization itself works
fine and non-MSVC code is unchanged, so I think we can live with that.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18755 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Christian Stimming 2010-02-27 18:41:49 +00:00
parent 9d6160cfd4
commit 1ddcb88d0c
9 changed files with 213 additions and 149 deletions

View File

@ -4674,19 +4674,25 @@ xaccAccountForEachTransaction(const Account *acc, TransactionCallback proc,
/* ================================================================ */ /* ================================================================ */
/* QofObject function implementation and registration */ /* QofObject function implementation and registration */
#ifdef _MSC_VER
/* MSVC compiler doesn't have C99 "designated initializers"
* so we wrap them in a macro that is empty on MSVC. */
# define DI(x) /* */
#else
# define DI(x) x
#endif
static QofObject account_object_def = { static QofObject account_object_def = {
.interface_version = QOF_OBJECT_VERSION, DI(.interface_version =) QOF_OBJECT_VERSION,
.e_type = GNC_ID_ACCOUNT, DI(.e_type =) GNC_ID_ACCOUNT,
.type_label = "Account", DI(.type_label =) "Account",
.create = (gpointer)xaccMallocAccount, DI(.create =) (gpointer)xaccMallocAccount,
.book_begin = NULL, DI(.book_begin =) NULL,
.book_end = NULL, DI(.book_end =) NULL,
.is_dirty = qof_collection_is_dirty, DI(.is_dirty =) qof_collection_is_dirty,
.mark_clean = qof_collection_mark_clean, DI(.mark_clean =) qof_collection_mark_clean,
.foreach = qof_collection_foreach, DI(.foreach =) qof_collection_foreach,
.printable = (const char* (*)(gpointer)) xaccAccountGetName, DI(.printable =) (const char* (*)(gpointer)) xaccAccountGetName,
.version_cmp = (int (*)(gpointer,gpointer)) qof_instance_version_cmp, DI(.version_cmp =) (int (*)(gpointer,gpointer)) qof_instance_version_cmp,
}; };
gboolean xaccAccountRegister (void) gboolean xaccAccountRegister (void)

View File

@ -161,17 +161,24 @@ sxtg_mark_clean(QofCollection *col)
g_list_free(descendants); g_list_free(descendants);
} }
#ifdef _MSC_VER
/* MSVC compiler doesn't have C99 "designated initializers"
* so we wrap them in a macro that is empty on MSVC. */
# define DI(x) /* */
#else
# define DI(x) x
#endif
static QofObject sxtg_object_def = static QofObject sxtg_object_def =
{ {
.interface_version = QOF_OBJECT_VERSION, DI(.interface_version =) QOF_OBJECT_VERSION,
.e_type = GNC_ID_SXTG, DI(.e_type =) GNC_ID_SXTG,
.type_label = "Scheduled Transaction Templates", DI(.type_label =) "Scheduled Transaction Templates",
.book_begin = sxtg_book_begin, DI(.book_begin =) sxtg_book_begin,
.book_end = sxtg_book_end, DI(.book_end =) sxtg_book_end,
.is_dirty = sxtg_is_dirty, DI(.is_dirty =) sxtg_is_dirty,
.mark_clean = sxtg_mark_clean, DI(.mark_clean =) sxtg_mark_clean,
.foreach = NULL, DI(.foreach =) NULL,
.printable = NULL, DI(.printable =) NULL,
}; };
/* ====================================================================== */ /* ====================================================================== */
@ -307,32 +314,32 @@ book_sxlist_notsaved(const QofCollection *col)
static QofObject sxes_object_def = static QofObject sxes_object_def =
{ {
.interface_version = QOF_OBJECT_VERSION, DI(.interface_version =) QOF_OBJECT_VERSION,
.e_type = GNC_ID_SXES, DI(.e_type =) GNC_ID_SXES,
.type_label = "Scheduled Transactions List", DI(.type_label =) "Scheduled Transactions List",
.create = NULL, DI(.create =) NULL,
.book_begin = book_sxes_setup, DI(.book_begin =) book_sxes_setup,
.book_end = book_sxes_end, DI(.book_end =) book_sxes_end,
.is_dirty = book_sxlist_notsaved, DI(.is_dirty =) book_sxlist_notsaved,
.mark_clean = book_sxns_mark_saved, DI(.mark_clean =) book_sxns_mark_saved,
.foreach = NULL, DI(.foreach =) NULL,
.printable = NULL, DI(.printable =) NULL,
.version_cmp = NULL DI(.version_cmp =) NULL
}; };
static QofObject sxtt_object_def = static QofObject sxtt_object_def =
{ {
.interface_version = QOF_OBJECT_VERSION, DI(.interface_version =) QOF_OBJECT_VERSION,
.e_type = GNC_ID_SXTT, DI(.e_type =) GNC_ID_SXTT,
.type_label = "Scheduled Transaction Templates", DI(.type_label =) "Scheduled Transaction Templates",
.create = NULL, DI(.create =) NULL,
.book_begin = NULL, DI(.book_begin =) NULL,
.book_end = NULL, DI(.book_end =) NULL,
.is_dirty = NULL, DI(.is_dirty =) NULL,
.mark_clean = NULL, DI(.mark_clean =) NULL,
.foreach = NULL, DI(.foreach =) NULL,
.printable = NULL, DI(.printable =) NULL,
.version_cmp = NULL, DI(.version_cmp =) NULL,
}; };
gboolean gboolean

View File

@ -859,19 +859,26 @@ gnc_sx_get_defer_instances( SchedXaction *sx )
return sx->deferredList; return sx->deferredList;
} }
#ifdef _MSC_VER
/* MSVC compiler doesn't have C99 "designated initializers"
* so we wrap them in a macro that is empty on MSVC. */
# define DI(x) /* */
#else
# define DI(x) x
#endif
static QofObject SXDesc = static QofObject SXDesc =
{ {
.interface_version = QOF_OBJECT_VERSION, DI(.interface_version =) QOF_OBJECT_VERSION,
.e_type = GNC_SX_ID, DI(.e_type =) GNC_SX_ID,
.type_label = "Scheduled Transaction", DI(.type_label =) "Scheduled Transaction",
.create = (gpointer)xaccSchedXactionMalloc, DI(.create =) (gpointer)xaccSchedXactionMalloc,
.book_begin = NULL, DI(.book_begin =) NULL,
.book_end = NULL, DI(.book_end =) NULL,
.is_dirty = qof_collection_is_dirty, DI(.is_dirty =) qof_collection_is_dirty,
.mark_clean = qof_collection_mark_clean, DI(.mark_clean =) qof_collection_mark_clean,
.foreach = qof_collection_foreach, DI(.foreach =) qof_collection_foreach,
.printable = NULL, DI(.printable =) NULL,
.version_cmp = (int (*)(gpointer, gpointer)) qof_instance_version_cmp, DI(.version_cmp =) (int (*)(gpointer, gpointer)) qof_instance_version_cmp,
}; };
gboolean gboolean

View File

@ -1780,18 +1780,25 @@ xaccSplitUnvoid(Split *split)
/* Hook into the QofObject registry */ /* Hook into the QofObject registry */
#ifdef _MSC_VER
/* MSVC compiler doesn't have C99 "designated initializers"
* so we wrap them in a macro that is empty on MSVC. */
# define DI(x) /* */
#else
# define DI(x) x
#endif
static QofObject split_object_def = { static QofObject split_object_def = {
.interface_version = QOF_OBJECT_VERSION, DI(.interface_version =) QOF_OBJECT_VERSION,
.e_type = GNC_ID_SPLIT, DI(.e_type =) GNC_ID_SPLIT,
.type_label = "Split", DI(.type_label =) "Split",
.create = (gpointer)xaccMallocSplit, DI(.create =) (gpointer)xaccMallocSplit,
.book_begin = NULL, DI(.book_begin =) NULL,
.book_end = NULL, DI(.book_end =) NULL,
.is_dirty = qof_collection_is_dirty, DI(.is_dirty =) qof_collection_is_dirty,
.mark_clean = qof_collection_mark_clean, DI(.mark_clean =) qof_collection_mark_clean,
.foreach = qof_collection_foreach, DI(.foreach =) qof_collection_foreach,
.printable = (const char* (*)(gpointer)) xaccSplitGetMemo, DI(.printable =) (const char* (*)(gpointer)) xaccSplitGetMemo,
.version_cmp = (int (*)(gpointer, gpointer)) qof_instance_version_cmp, DI(.version_cmp =) (int (*)(gpointer, gpointer)) qof_instance_version_cmp,
}; };
static gpointer static gpointer

View File

@ -2028,19 +2028,27 @@ xaccTransFindSplitByAccount(const Transaction *trans, const Account *acc)
\********************************************************************/ \********************************************************************/
/* QofObject function implementation */ /* QofObject function implementation */
#ifdef _MSC_VER
/* MSVC compiler doesn't have C99 "designated initializers"
* so we wrap them in a macro that is empty on MSVC. */
# define DI(x) /* */
#else
# define DI(x) x
#endif
/* Hook into the QofObject registry */ /* Hook into the QofObject registry */
static QofObject trans_object_def = { static QofObject trans_object_def = {
.interface_version = QOF_OBJECT_VERSION, DI(.interface_version =) QOF_OBJECT_VERSION,
.e_type = GNC_ID_TRANS, DI(.e_type =) GNC_ID_TRANS,
.type_label = "Transaction", DI(.type_label =) "Transaction",
.create = (gpointer)xaccMallocTransaction, DI(.create =) (gpointer)xaccMallocTransaction,
.book_begin = NULL, DI(.book_begin =) NULL,
.book_end = NULL, DI(.book_end =) NULL,
.is_dirty = qof_collection_is_dirty, DI(.is_dirty =) qof_collection_is_dirty,
.mark_clean = qof_collection_mark_clean, DI(.mark_clean =) qof_collection_mark_clean,
.foreach = qof_collection_foreach, DI(.foreach =) qof_collection_foreach,
.printable = (const char* (*)(gpointer)) xaccTransGetDescription, DI(.printable =) (const char* (*)(gpointer)) xaccTransGetDescription,
.version_cmp = (int (*)(gpointer,gpointer)) qof_instance_version_cmp, DI(.version_cmp =) (int (*)(gpointer,gpointer)) qof_instance_version_cmp,
}; };
static gboolean static gboolean

View File

@ -600,20 +600,28 @@ gnc_budget_get_default (QofBook *book)
return bgt; return bgt;
} }
#ifdef _MSC_VER
/* MSVC compiler doesn't have C99 "designated initializers"
* so we wrap them in a macro that is empty on MSVC. */
# define DI(x) /* */
#else
# define DI(x) x
#endif
/* Define the QofObject. */ /* Define the QofObject. */
static QofObject budget_object_def = static QofObject budget_object_def =
{ {
.interface_version = QOF_OBJECT_VERSION, DI(.interface_version =) QOF_OBJECT_VERSION,
.e_type = GNC_ID_BUDGET, DI(.e_type =) GNC_ID_BUDGET,
.type_label = "Budget", DI(.type_label =) "Budget",
.create = (gpointer)gnc_budget_new, DI(.create =) (gpointer)gnc_budget_new,
.book_begin = NULL, DI(.book_begin =) NULL,
.book_end = NULL, DI(.book_end =) NULL,
.is_dirty = qof_collection_is_dirty, DI(.is_dirty =) qof_collection_is_dirty,
.mark_clean = qof_collection_mark_clean, DI(.mark_clean =) qof_collection_mark_clean,
.foreach = qof_collection_foreach, DI(.foreach =) qof_collection_foreach,
.printable = (const char* (*)(gpointer)) gnc_budget_get_name, DI(.printable =) (const char* (*)(gpointer)) gnc_budget_get_name,
.version_cmp = (int (*)(gpointer, gpointer)) qof_instance_version_cmp, DI(.version_cmp =) (int (*)(gpointer, gpointer)) qof_instance_version_cmp,
}; };

View File

@ -2312,30 +2312,37 @@ gnc_commodity_table_add_default_data(gnc_commodity_table *table, QofBook *book)
********************************************************************/ ********************************************************************/
/* QofObject function implementation and registration */ /* QofObject function implementation and registration */
#ifdef _MSC_VER
/* MSVC compiler doesn't have C99 "designated initializers"
* so we wrap them in a macro that is empty on MSVC. */
# define DI(x) /* */
#else
# define DI(x) x
#endif
static QofObject commodity_object_def = static QofObject commodity_object_def =
{ {
.interface_version = QOF_OBJECT_VERSION, DI(.interface_version =) QOF_OBJECT_VERSION,
.e_type = GNC_ID_COMMODITY, DI(.e_type =) GNC_ID_COMMODITY,
.type_label = "Commodity", DI(.type_label =) "Commodity",
.book_begin = NULL, DI(.book_begin =) NULL,
.book_end = NULL, DI(.book_end =) NULL,
.is_dirty = qof_collection_is_dirty, DI(.is_dirty =) qof_collection_is_dirty,
.mark_clean = qof_collection_mark_clean, DI(.mark_clean =) qof_collection_mark_clean,
.foreach = qof_collection_foreach, DI(.foreach =) qof_collection_foreach,
.printable = (const char* (*)(gpointer)) gnc_commodity_get_fullname, DI(.printable =) (const char* (*)(gpointer)) gnc_commodity_get_fullname,
}; };
static QofObject namespace_object_def = static QofObject namespace_object_def =
{ {
.interface_version = QOF_OBJECT_VERSION, DI(.interface_version =) QOF_OBJECT_VERSION,
.e_type = GNC_ID_COMMODITY_NAMESPACE, DI(.e_type =) GNC_ID_COMMODITY_NAMESPACE,
.type_label = "Namespace", DI(.type_label =) "Namespace",
.book_begin = NULL, DI(.book_begin =) NULL,
.book_end = NULL, DI(.book_end =) NULL,
.is_dirty = NULL, DI(.is_dirty =) NULL,
.mark_clean = NULL, DI(.mark_clean =) NULL,
.foreach = NULL, DI(.foreach =) NULL,
.printable = NULL, DI(.printable =) NULL,
}; };
static void static void
@ -2370,17 +2377,17 @@ commodity_table_book_end (QofBook *book)
static QofObject commodity_table_object_def = static QofObject commodity_table_object_def =
{ {
.interface_version = QOF_OBJECT_VERSION, DI(.interface_version =) QOF_OBJECT_VERSION,
.e_type = GNC_ID_COMMODITY_TABLE, DI(.e_type =) GNC_ID_COMMODITY_TABLE,
.type_label = "CommodityTable", DI(.type_label =) "CommodityTable",
.create = NULL, DI(.create =) NULL,
.book_begin = commodity_table_book_begin, DI(.book_begin =) commodity_table_book_begin,
.book_end = commodity_table_book_end, DI(.book_end =) commodity_table_book_end,
.is_dirty = qof_collection_is_dirty, DI(.is_dirty =) qof_collection_is_dirty,
.mark_clean = qof_collection_mark_clean, DI(.mark_clean =) qof_collection_mark_clean,
.foreach = NULL, DI(.foreach =) NULL,
.printable = NULL, DI(.printable =) NULL,
.version_cmp = NULL, DI(.version_cmp =) NULL,
}; };
gboolean gboolean

View File

@ -610,19 +610,26 @@ gnc_lot_get_latest_split (GNCLot *lot)
/* ============================================================= */ /* ============================================================= */
#ifdef _MSC_VER
/* MSVC compiler doesn't have C99 "designated initializers"
* so we wrap them in a macro that is empty on MSVC. */
# define DI(x) /* */
#else
# define DI(x) x
#endif
static QofObject gncLotDesc = static QofObject gncLotDesc =
{ {
.interface_version = QOF_OBJECT_VERSION, DI(.interface_version =) QOF_OBJECT_VERSION,
.e_type = GNC_ID_LOT, DI(.e_type =) GNC_ID_LOT,
.type_label = "Lot", DI(.type_label =) "Lot",
.create = (gpointer)gnc_lot_new, DI(.create =) (gpointer)gnc_lot_new,
.book_begin = NULL, DI(.book_begin =) NULL,
.book_end = NULL, DI(.book_end =) NULL,
.is_dirty = qof_collection_is_dirty, DI(.is_dirty =) qof_collection_is_dirty,
.mark_clean = qof_collection_mark_clean, DI(.mark_clean =) qof_collection_mark_clean,
.foreach = qof_collection_foreach, DI(.foreach =) qof_collection_foreach,
.printable = NULL, DI(.printable =) NULL,
.version_cmp = (int (*)(gpointer,gpointer))qof_instance_version_cmp, DI(.version_cmp =) (int (*)(gpointer,gpointer))qof_instance_version_cmp,
}; };

View File

@ -2479,34 +2479,41 @@ price_printable(gpointer obj)
return buff; return buff;
} }
#ifdef _MSC_VER
/* MSVC compiler doesn't have C99 "designated initializers"
* so we wrap them in a macro that is empty on MSVC. */
# define DI(x) /* */
#else
# define DI(x) x
#endif
static QofObject price_object_def = static QofObject price_object_def =
{ {
.interface_version = QOF_OBJECT_VERSION, DI(.interface_version =) QOF_OBJECT_VERSION,
.e_type = GNC_ID_PRICE, DI(.e_type =) GNC_ID_PRICE,
.type_label = "Price", DI(.type_label =) "Price",
.create = price_create, DI(.create =) price_create,
.book_begin = NULL, DI(.book_begin =) NULL,
.book_end = NULL, DI(.book_end =) NULL,
.is_dirty = qof_collection_is_dirty, DI(.is_dirty =) qof_collection_is_dirty,
.mark_clean = qof_collection_mark_clean, DI(.mark_clean =) qof_collection_mark_clean,
.foreach = price_foreach, DI(.foreach =) price_foreach,
.printable = price_printable, DI(.printable =) price_printable,
.version_cmp = NULL, DI(.version_cmp =) NULL,
}; };
static QofObject pricedb_object_def = static QofObject pricedb_object_def =
{ {
.interface_version = QOF_OBJECT_VERSION, DI(.interface_version =) QOF_OBJECT_VERSION,
.e_type = GNC_ID_PRICEDB, DI(.e_type =) GNC_ID_PRICEDB,
.type_label = "PriceDB", DI(.type_label =) "PriceDB",
.create = NULL, DI(.create =) NULL,
.book_begin = pricedb_book_begin, DI(.book_begin =) pricedb_book_begin,
.book_end = pricedb_book_end, DI(.book_end =) pricedb_book_end,
.is_dirty = qof_collection_is_dirty, DI(.is_dirty =) qof_collection_is_dirty,
.mark_clean = qof_collection_mark_clean, DI(.mark_clean =) qof_collection_mark_clean,
.foreach = NULL, DI(.foreach =) NULL,
.printable = NULL, DI(.printable =) NULL,
.version_cmp = NULL, DI(.version_cmp =) NULL,
}; };
gboolean gboolean