Logo
  • Manifesto
  • Changelog
  • Coding Style Guide
  • API
    • Directory hierarchy
    • Namespace hierarchy
    • API contents
      • Classes
      • Macros
      • Directories
      • Enumerations
      • Files
        • omni/core/Api.h
        • carb/memory/ArenaAllocator.h
        • omni/core/Assert.h
        • carb/assert/AssertUtils.h
        • carb/assets/AssetsTypes.h
        • carb/assets/AssetsUtils.h
        • carb/cpp20/Atomic.h
        • carb/audio/AudioStreamerUtils.h
        • carb/audio/AudioTypes.h
        • carb/audio/AudioUtils.h
        • tests/test.unit/omni.core/plugin/test.bar/BarImpl.cpp
        • carb/cpp20/Barrier.h
        • carb/cpp/Barrier.h
        • carb/extras/Base64.h
        • omni/structuredlog/BinarySerializer.h
        • carb/BindingsPythonTypes.h
        • carb/BindingsUtils.h
        • carb/cpp20/Bit.h
        • carb/cpp/Bit.h
        • carb/container/BufferedObject.h
        • omni/core/BuiltIn.h
        • carb/CarbWindows.h
        • carb/ClientUtils.h
        • omni/compiletime/CompileTime.h
        • omni/extras/ContainerHelper.h
        • omni/detail/ConvertsFromAnyCvRef.h
        • carb/extras/CpuInfo.h
        • carb/crashreporter/CrashReporterUtils.h
        • carb/extras/Debugging.h
        • carb/detail/DeferredLoad.h
        • carb/Defines.h
        • carb/delegate/Delegate.h
        • carb/tasking/Delegate.h
        • carb/delegate/detail/DelegateBase.h
        • omni/extras/DictHelpers.h
        • carb/dictionary/DictionaryUtils.h
        • carb/extras/EnvironmentVariable.h
        • carb/extras/EnvironmentVariableParser.h
        • carb/Error.h
        • carb/extras/Errors.h
        • carb/eventdispatcher/EventDispatcherTypes.h
        • omni/kit/EventSubscribers.h
        • carb/events/EventsUtils.h
        • carb/cpp17/Exception.h
        • omni/Expected.h
        • omni/detail/ExpectedImpl.h
        • omni/ext/ExtensionsUtils.h
        • omni/extras/FileSystemHelpers.h
        • carb/filesystem/FindFiles.h
        • carb/FindPlugins.h
        • omni/extras/ForceLink.h
          • Source file
          • OMNI_FORCE_SYMBOL_LINK
        • carb/Framework.h
        • omni/Function.h
        • omni/detail/FunctionImpl.h
        • carb/cpp17/Functional.h
        • carb/cpp/Functional.h
        • carb/thread/Futex.h
        • carb/thread/FutexImpl.h
        • carb/extras/HandleDatabase.h
        • omni/kit/IApp.h
        • omni/kit/IAppMessageBox.h
        • carb/assert/IAssert.h
        • carb/assets/IAssets.h
        • carb/assets/IAssetsBlob.h
        • carb/audio/IAudioCapture.h
        • omni/audio/experimental/IAudioCapture.h
        • carb/audio/IAudioData.h
        • carb/audio/IAudioDevice.h
        • carb/audio/IAudioGroup.h
        • carb/audio/IAudioPlayback.h
        • carb/audio/IAudioUtils.h
        • omni/platforminfo/ICpuInfo.gen.h
        • omni/platforminfo/ICpuInfo.h
        • carb/crashreporter/ICrashReporter.h
        • carb/dictionary/IDictionary.h
        • carb/eventdispatcher/IEventDispatcher.h
        • carb/events/IEvents.h
        • omni/ext/IExt.h
        • omni/ext/IExtensionData.gen.h
        • omni/ext/IExtensionData.h
        • omni/ext/IExtensionHooks.gen.h
        • omni/ext/IExtensionHooks.h
        • omni/ext/IExtensions.h
        • carb/tasking/IFiberEvents.h
        • carb/filesystem/IFileSystem.h
        • carb/input/IInput.h
        • omni/experimental/job/IJob.gen.h
        • omni/experimental/job/IJob.h
        • carb/l10n/IL10n.h
        • carb/launcher/ILauncher.h
        • omni/log/ILog.gen.h
        • omni/log/ILog.h
        • omni/log/ILogChannelFilter.gen.h
        • omni/log/ILogChannelFilter.h
        • carb/logging/ILogging.h
        • omni/platforminfo/IMemoryInfo.gen.h
        • omni/platforminfo/IMemoryInfo.h
        • omni/core/IObject.gen.h
        • carb/IObject.h
        • omni/core/IObject.h
        • omni/platforminfo/IOsInfo.gen.h
        • omni/platforminfo/IOsInfo.h
        • carb/profiler/IProfileMonitor.h
        • carb/profiler/IProfiler.h
        • omni/str/IReadOnlyCString.gen.h
        • omni/str/IReadOnlyCString.h
        • omni/kit/IRunLoopRunner.h
        • carb/dictionary/ISerializer.h
        • carb/settings/ISettings.h
        • carb/simplegui/ISimpleGui.h
        • examples/example.stats/include/carb/stats/IStats.h
        • omni/structuredlog/IStructuredLog.gen.h
        • omni/structuredlog/IStructuredLog.h
        • omni/structuredlog/IStructuredLogControl.gen.h
        • omni/structuredlog/IStructuredLogControl.h
        • omni/structuredlog/IStructuredLogExtraFields.gen.h
        • omni/structuredlog/IStructuredLogExtraFields.h
        • omni/structuredlog/IStructuredLogFromILog.gen.h
        • omni/structuredlog/IStructuredLogFromILog.h
        • omni/structuredlog/IStructuredLogSettings.gen.h
        • omni/structuredlog/IStructuredLogSettings.h
        • omni/structuredlog/IStructuredLogSettings2.gen.h
        • omni/structuredlog/IStructuredLogSettings2.h
        • carb/tasking/ITasking.h
        • carb/tasking/IThreadPool.h
        • carb/thread/IThreadUtil.h
        • carb/tokens/ITokens.h
        • omni/core/ITypeFactory.gen.h
        • omni/core/ITypeFactory.h
        • carb/variant/IVariant.h
        • omni/core/IWeakObject.gen.h
        • omni/core/IWeakObject.h
        • carb/cpp/detail/ImplData.h
        • carb/cpp/detail/ImplDummy.h
        • carb/input/InputProvider.h
        • carb/input/InputTypes.h
        • carb/input/InputUtils.h
        • carb/Interface.h
        • omni/core/Interface.h
        • carb/InterfaceUtils.h
        • examples/example.stats/plugins/carb.stats/Interfaces.cpp
        • carb/container/IntrusiveList.h
        • carb/container/IntrusiveUnorderedMultimap.h
        • omni/structuredlog/JsonSerializer.h
        • omni/structuredlog/JsonTree.h
        • omni/structuredlog/JsonTreeSerializer.h
        • omni/kit/KitUpdateOrder.h
        • carb/l10n/L10nUtils.h
        • carb/cpp20/Latch.h
        • carb/cpp/Latch.h
        • carb/launcher/LauncherUtils.h
        • carb/extras/Library.h
        • carb/container/LocklessQueue.h
        • carb/container/LocklessStack.h
        • carb/logging/Log.h
        • omni/log/LogChannel.h
        • carb/logging/Logger.h
        • carb/logging/LoggingTypes.h
        • carb/logging/LoggingUtils.h
        • carb/Memory.h
        • carb/cpp17/Memory.h
        • carb/cpp20/Memory.h
        • carb/cpp/Memory.h
        • carb/extras/MemoryUsage.h
        • omni/core/ModuleExports.h
        • omni/core/ModuleInfo.h
        • carb/thread/Mutex.h
        • carb/detail/NoexceptType.h
        • carb/cpp/Numeric.h
        • carb/ObjectUtils.h
        • omni/core/Omni.h
        • omni/core/OmniAttr.h
        • omni/core/OmniInit.h
        • carb/cpp17/Optional.h
        • carb/extras/Options.h
        • omni/extras/OutArrayUtils.h
        • omni/detail/ParamPack.h
        • carb/extras/Path.h
        • omni/extras/PathMap.h
        • omni/core/Platform.h
        • carb/PluginCoreUtils.h
        • carb/PluginInitializers.h
        • carb/PluginUtils.h
        • omni/detail/PointerIterator.h
        • carb/detail/PopBadMacros.h
        • omni/extras/PrivacySettings.h
        • carb/profiler/Profile.h
        • carb/profiler/ProfilerUtils.h
        • carb/detail/PushBadMacros.h
        • omni/python/PyBind.h
        • carb/container/RHUnorderedMap.h
        • carb/container/RHUnorderedMultimap.h
        • carb/container/RHUnorderedMultiset.h
        • carb/container/RHUnorderedSet.h
        • carb/RString.h
        • carb/RStringEnum.inl
        • carb/thread/RecursiveSharedMutex.h
        • omni/core/Result.gen.h
        • omni/core/Result.h
        • omni/core/ResultError.h
        • carb/container/RobinHoodImpl.h
        • omni/extras/RtxSettings.h
        • omni/extras/ScratchBuffer.h
        • carb/SdkVersion.h
        • carb/cpp20/Semaphore.h
        • carb/cpp/Semaphore.h
        • omni/extras/SettingsHelpers.h
        • carb/settings/SettingsUtils.h
        • omni/kit/SettingsUtils.h
        • carb/extras/SharedMemory.h
        • carb/thread/SharedMutex.h
        • carb/simplegui/SimpleGuiTypes.h
        • carb/cpp20/Span.h
        • carb/cpp/Span.h
        • omni/Span.h
        • carb/thread/Spinlock.h
        • carb/logging/StandardLogger.h
        • carb/logging/StandardLogger2.h
        • carb/StartupUtils.h
        • examples/example.stats/plugins/carb.stats/Stats.cpp
        • examples/example.stats/plugins/carb.stats/Stats.h
        • carb/cpp17/StdDef.h
        • carb/cpp/StdDef.h
        • omni/String.h
        • omni/extras/StringHelpers.h
        • carb/extras/StringSafe.h
        • carb/cpp17/StringView.h
        • carb/cpp/StringView.h
        • omni/StringView.h
        • omni/structuredlog/StringView.h
        • omni/structuredlog/StructuredLogCommon.h
        • omni/structuredlog/StructuredLogSettingsUtils.h
        • carb/detail/TSan.h
        • carb/tasking/TaskingHelpers.h
        • carb/tasking/TaskingTypes.h
        • carb/tasking/TaskingUtils.h
        • carb/extras/TestEnvironment.h
        • carb/thread/ThreadLocal.h
        • carb/tasking/ThreadPoolUtils.h
        • carb/extras/Tokens.h
        • carb/tokens/TokensUtils.h
        • carb/time/TscClock.h
        • carb/cpp17/Tuple.h
        • omni/core/TypeId.h
        • carb/cpp17/TypeTraits.h
        • carb/cpp20/TypeTraits.h
        • carb/cpp/TypeTraits.h
        • carb/Types.h
        • omni/core/Types.h
        • Undocumented.h
        • omni/extras/UniqueApp.h
        • carb/extras/Utf8Parser.h
        • carb/math/Util.h
        • carb/memory/Util.h
        • carb/process/Util.h
        • carb/thread/Util.h
        • carb/time/Util.h
        • carb/cpp17/Utility.h
        • carb/extras/Uuid.h
        • carb/extras/VariableSetup.h
        • carb/cpp17/Variant.h
        • carb/variant/VariantTypes.h
        • carb/variant/VariantUtils.h
        • omni/Vector.h
        • omni/detail/VectorDetail.h
        • carb/Version.h
        • omni/extras/Version.h
        • omni/kit/Wildcard.h
        • omni/str/Wildcard.h
        • omni/log/WildcardLogChannelFilter.h
        • carb/extras/WindowsPath.h
        • examples/example.windowing/example.windowing.native.app/example.windowing.cpp
        • examples/example.windowing/example.windowing.no.plugin.app/example.windowing.no.plugin.cpp
        • examples/example.windowing/example-glfw/glfw.cpp
        • examples/example.stats/example.stats/main.cpp
        • omni/extras/md5.h
      • Functions
      • Groups
      • Namespaces
      • Pages
      • Structs
      • Typedefs
      • Unions
      • Variables
  • License

Top Level

  • Carbonite Plugins/Interfaces
  • Omniverse Native Interfaces
  • Deploying a Carbonite Application

Components

  • Asserts
  • Audio
  • Crash Reporter
  • Function
  • Carbonite Input Plugin
  • Overview
  • Localization
  • Logging
  • Memory
  • Python Bindings
  • String
  • Tasking
  • Telemetry
  • Unicode

Guides

  • ABI Compatibility
  • Building
  • Testing
  • Packaging
  • Releasing
  • Using Valgrind
  • Carbonite Interface Walkthrough
  • Creating a New Omniverse Native Interface
  • Troubleshooting
  • Extending an Omniverse Native Interface Walkthrough
  • Using omni.bind

Documenting

  • Documentation Guidelines
  • Restructured Text Guide
  • C++ Documentation Guide
  • Python Documentation Guide
carbonite
  • »
  • Carbonite SDK API »
  • Directories »
  • omni »
  • omni/extras »
  • omni/extras/ForceLink.h »
  • omni/extras/ForceLink.h
  •  

omni/extras/ForceLink.h

File members: omni/extras/ForceLink.h

// Copyright (c) 2021-2023, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once

#include "../core/Platform.h"

#if OMNI_PLATFORM_WINDOWS
// see below for why we unfortunately either need this or to forward declare SetLastError()
// directly here instead of using something like strerror_s() on Windows.
#    include "../../carb/CarbWindows.h"
#endif

namespace omni
{
namespace extras
{

class ForceSymbolLink
{
public:
    ForceSymbolLink(void* ptr)
    {
#if OMNI_PLATFORM_WINDOWS
        // On Windows, we unfortunately can't call into something like strerror_s() to
        // accomplish this task because the CRT is statically linked to the module that
        // will be using this.  That would make the function we're passing the symbol
        // to local and therefore the symbol will still be discardable.  Instead, we'll
        // pass the address to SetLastError() which will always be available from 'kernel32'.
        SetLastError(static_cast<DWORD>(reinterpret_cast<uintptr_t>(ptr)));
#else
        char* str;
        CARB_UNUSED(str);
        str = strerror(static_cast<int>(reinterpret_cast<uintptr_t>(ptr)));
#endif
    }
};

} // namespace extras
} // namespace omni

#define OMNI_FORCE_SYMBOL_LINK(symbol_, tag_)                                                                          \
    static omni::extras::ForceSymbolLink CARB_JOIN(                                                                    \
        g_forceLink##tag_##_, CARB_JOIN(CARB_JOIN(__COUNTER__, _), __LINE__))(&(symbol_))

© Copyright 2018-2024, NVIDIA. Last updated on Apr 29, 2024.