mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Fix ptr-comparison-to-string-literal error
A new error raised in the latest versions of gcc and clang. The address of string literals is undefined in the C standard so the compiler raises an error if one tries to test for string equality by comparing them. A better fix would be to replace QOF_ID strings with an int-based identifier; an even better one would get rid of QOF_ID entirely and use the C++ type system.
This commit is contained in:
parent
d642397dc4
commit
1c5561714d
@ -96,27 +96,7 @@ typedef struct QofCollection_s QofCollection;
|
||||
#define QOF_ID_BOOK "Book"
|
||||
#define QOF_ID_SESSION "Session"
|
||||
|
||||
/** Inline string comparison; compiler will optimize away most of this */
|
||||
#ifndef _MSC_VER
|
||||
# define QSTRCMP(da,db) ({ \
|
||||
gint val = 0; \
|
||||
if ((da) && (db)) { \
|
||||
if ((da) != (db)) { \
|
||||
val = strcmp ((da), (db)); \
|
||||
} \
|
||||
} else \
|
||||
if ((!(da)) && (db)) { \
|
||||
val = -1; \
|
||||
} else \
|
||||
if ((da) && (!(db))) { \
|
||||
val = 1; \
|
||||
} \
|
||||
val; /* block assumes value of last statement */ \
|
||||
})
|
||||
#else
|
||||
/* MSVC: Simply use g_strcmp */
|
||||
# define QSTRCMP g_strcmp0
|
||||
#endif
|
||||
#define QSTRCMP g_strcmp0
|
||||
|
||||
/** return TRUE if object is of the given type */
|
||||
#define QOF_CHECK_TYPE(obj,type) (((obj) != NULL) && \
|
||||
|
Loading…
Reference in New Issue
Block a user