gpt4 book ai didi

c - osx 构建失败

转载 作者:行者123 更新时间:2023-11-30 19:08:12 24 4
gpt4 key购买 nike

我的代码是使用 Linux 和 OpenBSD 构建的。现在我希望它用 osx 构建,但我从 travis-ci 收到这个错误,我不完全理解。

^

In file included from edit.c:1:

./sh.h:436:8: error: expected ')'

/usr/include/secure/_string.h:105:44: note: expanded from macro 'strlcpy'

__builtin___strlcpy_chk (dest, src, len, __darwin_obsz (dest))

^

/usr/include/secure/_common.h:39:62: note: expanded from macro '__darwin_obsz'

#define __darwin_obsz(object) __builtin_object_size (object, _USE_FORTIFY_LEVEL > 1 ? 1 : 0)

^

/usr/include/secure/_common.h:30:32: note: expanded from macro '_USE_FORTIFY_LEVEL'

# define _USE_FORTIFY_LEVEL 2

^

./sh.h:436:8: note: to match this '('

/usr/include/secure/_string.h:105:44: note: expanded from macro 'strlcpy'

__builtin___strlcpy_chk (dest, src, len, __darwin_obsz (dest))

^

/usr/include/secure/_common.h:39:53: note: expanded from macro '__darwin_obsz'

#define __darwin_obsz(object) __builtin_object_size (object, _USE_FORTIFY_LEVEL > 1 ? 1 : 0)

^

In file included from edit.c:1:

./sh.h:436:8: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]

size_t strlcpy(char *, const char *, size_t);

^

/usr/include/secure/_string.h:105:44: note: expanded from macro 'strlcpy'

__builtin___strlcpy_chk (dest, src, len, __darwin_obsz (dest))

^

/usr/include/secure/_common.h:39:31: note: expanded from macro '__darwin_obsz'

#define __darwin_obsz(object) __builtin_object_size (object, _USE_FORTIFY_LEVEL > 1 ? 1 : 0)

^

In file included from edit.c:1:

./sh.h:436:8: error: conflicting types for '__builtin___strlcpy_chk'

/usr/include/secure/_string.h:105:3: note: expanded from macro 'strlcpy'

__builtin___strlcpy_chk (dest, src, len, __darwin_obsz (dest))

^

./sh.h:436:8: note: '__builtin___strlcpy_chk' is a builtin with type 'unsigned long (char *, const char *, unsigned long, unsigned long)'

/usr/include/secure/_string.h:105:3: note: expanded from macro 'strlcpy'

__builtin___strlcpy_chk (dest, src, len, __darwin_obsz (dest))

我的宏是

#ifndef strlcpy
/* Linux has no concept of strlcpy(). */
#define strlcpy(x, y, z) snprintf((x), (z), "%s", (y))
#endif

我知道 osx 和 OpenBSD 有 strlcpy 但我不知道如何处理它。

我能做些什么呢?

最佳答案

这段代码:

#include <string.h>

#ifndef strlcpy
/* Linux has no concept of strlcpy(). */
#define strlcpy(x, y, z) snprintf((x), (z), "%s", (y))
#endif

int main() {
char a[1];
char b[1];
strlcpy(a, b, 1);
return 0;
}

在 macOS 上编译得很好。我知道 Travis-CI 最近禁用了对旧 XCode 版本的支持。也许这就是问题所在?

关于c - osx 构建失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45773708/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com