#include <string>
#ifdef TVG_BUILD
- #ifdef _MSC_VER
+ #if defined(_MSC_VER) && !defined(__clang__)
#define TVG_EXPORT __declspec(dllexport)
#define TVG_DEPRECATED __declspec(deprecated)
#else
/************************************************************************/
//clz: count leading zero’s
-#ifdef _MSC_VER
+#if defined(_MSC_VER) && !defined(__clang__)
#include <intrin.h>
static uint32_t __inline _clz(uint32_t value)
{
#define TVG_LOG_TAG "thorvg"
+#ifdef __clang__
+ #define strncpy strncpy_s
+ #define strdup _strdup
+#endif
+
//TVG class identifier values
#define TVG_CLASS_ID_UNDEFINED 0
#define TVG_CLASS_ID_SHAPE 1
#include <alloca.h>
#endif
+static FILE* _fopen(const char* filename, const char* mode)
+{
+#ifdef __clang__
+ FILE *fp;
+ auto err = fopen_s(&fp, filename, mode);
+ if (err != 0) return nullptr;
+ return fp;
+#else
+ auto fp = fopen(filename, mode);
+ if (!fp) return nullptr;
+ return fp;
+#endif
+}
+
#define SIZE(A) sizeof(A)
/************************************************************************/
memcpy(uncompressed, &compressedSizeBits, TVG_HEADER_COMPRESSED_SIZE_BITS);
//Good optimization, flush to file.
- auto fp = fopen(path.c_str(), "w+");
+ auto fp = _fopen(path.c_str(), "w+");
if (!fp) goto fail;
//write header
bool TvgSaver::flushTo(const std::string& path)
{
- auto fp = fopen(path.c_str(), "w+");
+ auto fp = _fopen(path.c_str(), "w+");
if (!fp) return false;
if (fwrite(buffer.data, SIZE(uint8_t), buffer.count, fp) == 0) {