mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 21:53:41 +00:00
all: fixing clang warnings
fopen->fopen_s, strdup -> _strdup, strncpy -> strncpy_s __declspec(dllexport) -> __attribute__ ((visibility ("default")))
This commit is contained in:
parent
d67517337c
commit
e7c3a91aa1
4 changed files with 24 additions and 5 deletions
|
@ -18,7 +18,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#ifdef TVG_BUILD
|
#ifdef TVG_BUILD
|
||||||
#ifdef _MSC_VER
|
#if defined(_MSC_VER) && !defined(__clang__)
|
||||||
#define TVG_EXPORT __declspec(dllexport)
|
#define TVG_EXPORT __declspec(dllexport)
|
||||||
#define TVG_DEPRECATED __declspec(deprecated)
|
#define TVG_DEPRECATED __declspec(deprecated)
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
|
|
||||||
//clz: count leading zero’s
|
//clz: count leading zero’s
|
||||||
#ifdef _MSC_VER
|
#if defined(_MSC_VER) && !defined(__clang__)
|
||||||
#include <intrin.h>
|
#include <intrin.h>
|
||||||
static uint32_t __inline _clz(uint32_t value)
|
static uint32_t __inline _clz(uint32_t value)
|
||||||
{
|
{
|
||||||
|
|
|
@ -48,6 +48,11 @@ using namespace tvg;
|
||||||
#define TVG_FALLTHROUGH
|
#define TVG_FALLTHROUGH
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __clang__
|
||||||
|
#define strncpy strncpy_s
|
||||||
|
#define strdup _strdup
|
||||||
|
#endif
|
||||||
|
|
||||||
//TVG class identifier values
|
//TVG class identifier values
|
||||||
#define TVG_CLASS_ID_UNDEFINED 0
|
#define TVG_CLASS_ID_UNDEFINED 0
|
||||||
#define TVG_CLASS_ID_SHAPE 1
|
#define TVG_CLASS_ID_SHAPE 1
|
||||||
|
|
|
@ -31,6 +31,20 @@
|
||||||
#include <alloca.h>
|
#include <alloca.h>
|
||||||
#endif
|
#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)
|
#define SIZE(A) sizeof(A)
|
||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
|
@ -181,7 +195,7 @@ bool TvgSaver::saveEncoding(const std::string& path)
|
||||||
memcpy(uncompressed, &compressedSizeBits, TVG_HEADER_COMPRESSED_SIZE_BITS);
|
memcpy(uncompressed, &compressedSizeBits, TVG_HEADER_COMPRESSED_SIZE_BITS);
|
||||||
|
|
||||||
//Good optimization, flush to file.
|
//Good optimization, flush to file.
|
||||||
auto fp = fopen(path.c_str(), "w+");
|
auto fp = _fopen(path.c_str(), "w+");
|
||||||
if (!fp) goto fail;
|
if (!fp) goto fail;
|
||||||
|
|
||||||
//write header
|
//write header
|
||||||
|
@ -204,7 +218,7 @@ fail:
|
||||||
|
|
||||||
bool TvgSaver::flushTo(const std::string& path)
|
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 (!fp) return false;
|
||||||
|
|
||||||
if (fwrite(buffer.data, SIZE(uint8_t), buffer.count, fp) == 0) {
|
if (fwrite(buffer.data, SIZE(uint8_t), buffer.count, fp) == 0) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue