Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

About project configuration #263

Open
AiXanadu opened this issue Jul 26, 2024 · 1 comment
Open

About project configuration #263

AiXanadu opened this issue Jul 26, 2024 · 1 comment

Comments

@AiXanadu
Copy link

When will we support MSVC compiler?
At this stage, some configurations are not very friendly to MSVC.
Will it support static compilation and linking and DllMan multiple definition issues?
If possible, could you please support CMake configuration?

@star-hengxing
Copy link

To support msvc, need someone port this code.

https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html

libplist/src/bplist.c

Lines 90 to 96 in 3daee60

#define get_unaligned(ptr) \
({ \
struct __attribute__((packed)) { \
typeof(*(ptr)) __v; \
} *__p = (void *) (ptr); \
__p->__v; \
})

libplist/src/bplist.c

Lines 151 to 161 in 3daee60

#define UINT_TO_HOST(x, n) \
({ \
union plist_uint_ptr __up; \
__up.src = ((n) > 8) ? (x) + ((n) - 8) : (x); \
((n) >= 8 ? be64toh( get_unaligned(__up.u64ptr) ) : \
((n) == 4 ? be32toh( get_unaligned(__up.u32ptr) ) : \
((n) == 2 ? be16toh( get_unaligned(__up.u16ptr) ) : \
((n) == 1 ? *__up.u8ptr : \
beNtoh( get_unaligned(__up.u64ptr), n) \
)))); \
})


Currently, we can use clang-cl + ms stl to build this library, and pass -Iinclude & plist.lib in my msvc project.
But I use xmake as build system, hope can give you some hint.

option("version", {default = "2.6.0"})

add_rules("mode.debug", "mode.release")

if not is_plat("windows", "mingw", "msys") then
    add_defines("HAVE_STRNDUP")
end

local version = get_config("version")
if version then
    set_version(version, {soname = true})
    add_defines("PACKAGE_VERSION=\"" .. version .. "\"")
end

target("plist")
    set_kind("$(kind)")
    add_files("libcnary/*.c|cnary.c", "src/*.c")
    add_includedirs("src", "include", "libcnary/include")
    add_headerfiles("include/(plist/*.h)")

    if is_kind("static") then
        add_defines("LIBPLIST_STATIC")
    end

Build

$ xmake f -c --toolchain=clang-cl
$ xmake

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants