string_cast.hpp merely detects whether the current compiler is NVCC (originally based on `if defined(__CUDACC__)` in glm/simd/platform.h) and throws an error if it is. This means string_cast.hpp cannot be included in any header which might ever be used in a CUDA project. Of course, glm::to_string can't be used in device (GPU) code. However, the current approach to stop this is both incorrect and unnecessary. __CUDACC__ will be defined in both host and device code compilation, and glm::to_string can obviously be used in host code. The correct define is __CUDA_ARCH__ (will be defined only if compiling device code). However, there's no problem if glm::to_string is defined (the header is included) while compiling device code, as long as it's not actually used in the device code. So, throwing an error if __CUDA_ARCH__ is defined would still prevent string_cast.hpp from being included in CUDA projects. There's actually no need for any manual check to see if glm::to_string is being used in device code, because the compiler will already check for that. It returns a std::string, which itself can't be used in device code, so it's unlikely a developer would try. And if they did, there would be errors that both glm::to_string and all the needed std::string constructors, stream operators, etc. are host-only functions.
47 lines
1.2 KiB
C++
47 lines
1.2 KiB
C++
/// @ref gtx_string_cast
|
|
/// @file glm/gtx/string_cast.hpp
|
|
///
|
|
/// @see core (dependence)
|
|
/// @see gtx_integer (dependence)
|
|
/// @see gtx_quaternion (dependence)
|
|
///
|
|
/// @defgroup gtx_string_cast GLM_GTX_string_cast
|
|
/// @ingroup gtx
|
|
///
|
|
/// Include <glm/gtx/string_cast.hpp> to use the features of this extension.
|
|
///
|
|
/// Setup strings for GLM type values
|
|
|
|
#pragma once
|
|
|
|
// Dependency:
|
|
#include "../glm.hpp"
|
|
#include "../gtc/type_precision.hpp"
|
|
#include "../gtc/quaternion.hpp"
|
|
#include "../gtx/dual_quaternion.hpp"
|
|
#include <string>
|
|
#include <cmath>
|
|
|
|
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
|
|
# ifndef GLM_ENABLE_EXPERIMENTAL
|
|
# pragma message("GLM: GLM_GTX_string_cast is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it.")
|
|
# else
|
|
# pragma message("GLM: GLM_GTX_string_cast extension included")
|
|
# endif
|
|
#endif
|
|
|
|
namespace glm
|
|
{
|
|
/// @addtogroup gtx_string_cast
|
|
/// @{
|
|
|
|
/// Create a string from a GLM vector or matrix typed variable.
|
|
/// @see gtx_string_cast extension.
|
|
template<typename genType>
|
|
GLM_FUNC_DECL std::string to_string(genType const& x);
|
|
|
|
/// @}
|
|
}//namespace glm
|
|
|
|
#include "string_cast.inl"
|