]> git.ipfire.org Git - thirdparty/json-c.git/commitdiff
Issue #941: fix "defined but not used" errors when building with a c++ compiler.
authorEric Hawicz <erh+git@nimenees.com>
Sat, 11 Jul 2026 13:28:49 +0000 (09:28 -0400)
committerEric Hawicz <erh+git@nimenees.com>
Sat, 11 Jul 2026 13:28:49 +0000 (09:28 -0400)
json_object.h
linkhash.h

index 7edb63d4f8cbeb75e8d16eaea1726feaec9f4ca7..2cd94906e756d520efce4b7d0007c27d55e27251 100644 (file)
@@ -488,7 +488,7 @@ JSON_EXPORT void json_object_object_del(struct json_object *obj, const char *key
  * @param val the local name for the json_object* object variable defined in
  *            the body
  */
-#if defined(__GNUC__) && !defined(__STRICT_ANSI__) && (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L)
+#if defined(__GNUC__) && !defined(__STRICT_ANSI__) && (defined(__cplusplus) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L))
 
 #define json_object_object_foreach(obj, key, val)                                \
        char *key = NULL;                                                        \
@@ -520,7 +520,7 @@ JSON_EXPORT void json_object_object_del(struct json_object *obj, const char *key
                         : 0);                                                 \
             entry##key = entry_next##key)
 
-#endif /* defined(__GNUC__) && !defined(__STRICT_ANSI__) && (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) */
+#endif
 
 /** Iterate through all keys and values of an object (ANSI C Safe)
  * @param obj the json_object instance
index 5ad17cf2d24b3a2ad2c5e2e510e8b59379ec03cb..48fb7c0b0a32b7957cc73720640557de322d4db6 100644 (file)
@@ -345,7 +345,7 @@ int lh_table_resize(struct lh_table *t, int new_size);
 /**
  * @deprecated Don't use this outside of linkhash.h:
  */
-#if !defined (__STDC_VERSION__) || (__STDC_VERSION__ < 199901L)
+#if !defined(__cplusplus) && (!defined (__STDC_VERSION__) || (__STDC_VERSION__ < 199901L))
 /* C89 compilers like VS2010 can't handle inline funcs, so skip it there,
    note: this also applies to -std=c89 in GCC! */
 #define _LH_INLINE