phoboslab / qoi

The “Quite OK Image Format” for fast, lossless image compression
MIT License
6.85k stars 327 forks source link

Resolve some warnings when MSVC warning level is 4 #240

Open Demonese opened 1 year ago

Demonese commented 1 year ago
image
Demonese commented 1 year ago

Test build system: CMakeLists.txt

cmake_minimum_required(VERSION 3.24)
project(qoi)

add_library(libqoi)
if(MSVC)
    target_compile_options(libqoi PRIVATE
        "/utf-8"
        "/W4"
    )
else()
    target_compile_options(libqoi PRIVATE
        "-Wall"
        "-Wextra"
        "-Wpedantic"
        "-Werror"
    )
endif()
if(WIN32)
    target_compile_definitions(libqoi PRIVATE
        _CRT_SECURE_NO_WARNINGS
    )
endif()
set_target_properties(libqoi PROPERTIES
    C_STANDARD 17
    C_STANDARD_REQUIRED ON
)
target_compile_definitions(libqoi PRIVATE
    QOI_IMPLEMENTATION
)
target_include_directories(libqoi PUBLIC
    .
)
target_sources(libqoi PRIVATE
    qoi.h
    qoi.c
)

qoi.c

#ifndef QOI_IMPLEMENTATION
#define QOI_IMPLEMENTATION
#endif
#include "qoi.h"