bytedance / sonic-cpp

A fast JSON serializing & deserializing library, accelerated by SIMD.
Apache License 2.0
835 stars 101 forks source link

支持mingw平台吗?尝试编译会报错 #76

Closed heheda123123 closed 1 year ago

heheda123123 commented 1 year ago
package("sonic-cpp")
    set_kind("library", {headeronly = true})
    set_homepage("https://github.com/bytedance/sonic-cpp")
    set_description("A fast JSON serializing & deserializing library, accelerated by SIMD.")
    set_license("Apache-2.0")

    add_urls("https://github.com/bytedance/sonic-cpp/archive/refs/tags/v$(version).zip")
    add_versions("1.0.0", "409441bfc8b8b9fea8641dc0a0cdfaeed784246066a5c49fc7d6e74c39999f7b")

    add_cxxflags("-march=haswell")

    on_install("linux", "mingw", function (package)
        os.cp("include", package:installdir())
    end)

    on_test(function (package)
        assert(package:check_cxxsnippets({test = [[
            #include "sonic/sonic.h"

            #include <string>
            #include <iostream>

            void test()
            {
                std::string json = R"(
                    {
                    "a": 1,
                    "b": 2
                    }
                )";

                sonic_json::Document doc;
                doc.Parse(json);

                sonic_json::WriteBuffer wb;
                doc.Serialize(wb);
                std::cout << wb.ToString() << std::endl;
            }
        ]]}, {configs = {languages = "c++11"}}))
    end)

写了个xmake包,测试时,编译执行的命令如下

> C:\msys64\ucrt64\bin\x86_64-w64-mingw32-g++ -c -m64 -march=haswell -std=c++11 -isystem C:\Users\Administrator\AppData\Local\.xmake\packages\s\sonic-cpp\1.0.0\458df893a7ff477d92a940696c86a316\include -o C:\Users\ADMINI~1\AppData\Local\Temp\.xmake\230619\_EF9250378A744340846C152D91AA04B0.o C:\Users\ADMINI~1\AppData\Local\Temp\.xmake\230619\_4F3AD1D1A3F8411D9A0D827D5BABD56C.cpp
checking for flags (-fdiagnostics-color=always) ... ok
> x86_64-w64-mingw32-g++ "-fdiagnostics-color=always" "-m64"
> checking for c++ snippet(test)
checkinfo: ...amdir\core\sandbox\modules\import\core\tool\compiler.lua:84: @programdir\modules\core\tools\gcc.lua:721: In file included from C:\Users\Administrator\AppData\Local\.xmake\packages\s\sonic-cpp\1.0.0\458df893a7ff477d92a940696c86a316\include/sonic/dom/dynamicnode.h:24,
                 from C:\Users\Administrator\AppData\Local\.xmake\packages\s\sonic-cpp\1.0.0\458df893a7ff477d92a940696c86a316\include/sonic/sonic.h:19,
                 from C:\Users\ADMINI~1\AppData\Local\Temp\.xmake\230619\_4F3AD1D1A3F8411D9A0D827D5BABD56C.cpp:4:
C:\Users\Administrator\AppData\Local\.xmake\packages\s\sonic-cpp\1.0.0\458df893a7ff477d92a940696c86a316\include/sonic/dom/genericnode.h: In member function 'uint64_t sonic_json::GenericNode<NodeType>::getUintMax() const':
C:\Users\Administrator\AppData\Local\.xmake\packages\s\sonic-cpp\1.0.0\458df893a7ff477d92a940696c86a316\include/sonic/dom/genericnode.h:1069:32: error: 'uint' was not declared in this scope; did you mean 'int'?
 1069 |     return std::numeric_limits<uint>::max();
      |                                ^~~~
      |                                int
C:\Users\Administrator\AppData\Local\.xmake\packages\s\sonic-cpp\1.0.0\458df893a7ff477d92a940696c86a316\include/sonic/dom/genericnode.h:1069:36: error: template argument 1 is invalid
 1069 |     return std::numeric_limits<uint>::max();
      |                                    ^
liuq19 commented 1 year ago

感谢反馈,暂时不支持 windows 平台,后续会支持上

PakerYu commented 1 year ago

请尝试在 sonic-cpp/include/sonic/dom 下的 type.h 中加入

typedef unsigned int uint; 

@heheda123123

heheda123123 commented 1 year ago

可以了 https://github.com/xmake-io/xmake-repo/pull/2446