summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2024-01-16 14:14:02 -0800
committerAlan Coopersmith <alan.coopersmith@oracle.com>2024-01-16 14:48:15 -0800
commit42e39d102f5fc9e4834431b351e9d584052b4f75 (patch)
tree11fc777f865563e33bc19968b270bd3f8009c06d
parent5abe92c24fa3de28f740490228b66ca5f42f3322 (diff)
Fix 142 instances of -Wredundant-decls warning for RTASSERTVAR
./VBoxVideoIPRT.h:77:16: warning: redundant redeclaration of ‘RTASSERTVAR’ [-Wredundant-decls] 77 | extern int RTASSERTVAR[1] __attribute__((__unused__)), \ | ^~~~~~~~~~~ ./VBoxVideoIPRT.h:80:5: note: in expansion of macro ‘AssertCompile’ 80 | AssertCompile(sizeof(type) == (size)) | ^~~~~~~~~~~~~ ./VBoxVideoIPRT.h:73:12: note: previous declaration of ‘RTASSERTVAR’ with type ‘int[1]’ 73 | extern int RTASSERTVAR[1]; | ^~~~~~~~~~~ Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r--COPYING2
-rw-r--r--src/VBoxVideoIPRT.h25
2 files changed, 24 insertions, 3 deletions
diff --git a/COPYING b/COPYING
index 75e9178..f92d12f 100644
--- a/COPYING
+++ b/COPYING
@@ -1,6 +1,6 @@
Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com)
Copyright 2008 Red Hat, Inc.
-Copyright (C) 2005-2017 Oracle Corporation
+Copyright (C) 2005, 2024, Oracle and/or its affiliates.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
diff --git a/src/VBoxVideoIPRT.h b/src/VBoxVideoIPRT.h
index 305b1fb..7f64a94 100644
--- a/src/VBoxVideoIPRT.h
+++ b/src/VBoxVideoIPRT.h
@@ -1,6 +1,6 @@
/* $Id: VBoxVideoIPRT.h 118373 2017-10-13 17:01:46Z michael $ */
/*
- * Copyright (C) 2017 Oracle Corporation
+ * Copyright (C) 2017, 2024 Oracle and/or its affiliates.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -69,13 +69,34 @@ RT_C_DECLS_END
# include <string.h>
#endif /* !(defined(IN_XF86_MODULE) && !defined(NO_ANSIC)) */
+#ifndef __has_feature
+# define __has_feature(x) 0
+#endif
+#if __has_feature(cxx_static_assert) || __has_feature(c_static_assert)
+# define RTASSERT_HAVE_STATIC_ASSERT
+#elif defined(__GNUC__) && defined(__GXX_EXPERIMENTAL_CXX0X__)
+# define RTASSERT_HAVE_STATIC_ASSERT
+#elif !defined(__cplusplus) && (__STDC_VERSION__ >= 201112L)
+# define RTASSERT_HAVE_STATIC_ASSERT
+#endif
+
+#if !defined(__cplusplus) || !defined(RTASSERT_HAVE_STATIC_ASSERT)
RT_C_DECLS_BEGIN
extern int RTASSERTVAR[1];
RT_C_DECLS_END
+#endif
-#define AssertCompile(expr) \
+#ifdef RTASSERT_HAVE_STATIC_ASSERT
+# ifdef __cplusplus
+# define AssertCompile(expr) static_assert(!!(expr), #expr)
+# else
+# define AssertCompile(expr) _Static_assert(!!(expr), #expr)
+# endif
+#else
+# define AssertCompile(expr) \
extern int RTASSERTVAR[1] __attribute__((__unused__)), \
RTASSERTVAR[(expr) ? 1 : 0] __attribute__((__unused__))
+#endif
#define AssertCompileSize(type, size) \
AssertCompile(sizeof(type) == (size))
#define AssertPtrNullReturnVoid(a) do { } while(0)