From 42e39d102f5fc9e4834431b351e9d584052b4f75 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Tue, 16 Jan 2024 14:14:02 -0800 Subject: Fix 142 instances of -Wredundant-decls warning for RTASSERTVAR MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ./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 --- COPYING | 2 +- src/VBoxVideoIPRT.h | 25 +++++++++++++++++++++++-- 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 #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) -- cgit v1.2.3