Deprecation.h#

Fully qualified name: carb/Deprecation.h

File members: carb/Deprecation.h

// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: LicenseRef-NvidiaProprietary
//
// NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
// property and proprietary rights in and to this material, related
// documentation and any modifications thereto. Any use, reproduction,
// disclosure or distribution of this material and related documentation
// without an express license agreement from NVIDIA CORPORATION or
// its affiliates is strictly prohibited.

#pragma once

#include "Compiler.h"
#include "Defines.h"

#ifdef DOXYGEN_BUILD
#    define CARB_DEPRECATED(msg)
#    define CARB_DEPRECATED_IF(condition, msg)
#    define CARB_IGNORE_DEPRECATION_BEGIN
#    define CARB_IGNORE_DEPRECATION_END
#    define CARB_FILE_DEPRECATED
#else
#    define CARB_DEPRECATED(msg) CARB_ATTRIBUTE(deprecated(msg)) CARB_DECLSPEC(deprecated(msg))
// Helper macros for CARB_DEPRECATED_IF
#    define CARB_DEPRECATED_IF_IMPL_1(msg) CARB_DEPRECATED(msg)
#    define CARB_DEPRECATED_IF_IMPL_0(msg)
#    define CARB_DEPRECATED_IF_IMPL(condition, msg) CARB_JOIN(CARB_DEPRECATED_IF_IMPL_, condition)(msg)
#    define CARB_DEPRECATED_IF(condition, msg) CARB_DEPRECATED_IF_IMPL(condition, msg)
// Macro to suppress deprecation warnings at call site
#    if CARB_COMPILER_MSC
#        define CARB_IGNORE_DEPRECATION_BEGIN __pragma(warning(push)) __pragma(warning(disable : 4996))
#        define CARB_IGNORE_DEPRECATION_END __pragma(warning(pop))
#    elif CARB_COMPILER_GNUC || CARB_TOOLCHAIN_CLANG
#        define CARB_IGNORE_DEPRECATION_BEGIN                                                                          \
            _Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
#        define CARB_IGNORE_DEPRECATION_END _Pragma("GCC diagnostic pop")
#    else
#        define CARB_IGNORE_DEPRECATION_BEGIN
#        define CARB_IGNORE_DEPRECATION_END
#    endif
#    ifdef CARB_IGNORE_REMOVEFILE_WARNINGS
#        define CARB_FILE_DEPRECATED
#        define CARB_FILE_DEPRECATED_MSG(...)
#    else
#        define CARB_FILE_DEPRECATED_MSG(msg)                                                                          \
            CARB_WARNING(msg " (#define CARB_IGNORE_REMOVEFILE_WARNINGS to ignore these warnings)")
#        define CARB_FILE_DEPRECATED CARB_FILE_DEPRECATED_MSG("This file is no longer needed and will be removed soon")
#    endif
#endif