用于窗户,c,string,windows"/>

首页 > 解决方案 > 用于窗户

问题描述

我在我的 c 程序中使用 strlcpy、strlcat、strtok_r 函数。当我编译它时,我得到了

undefined reference to `strlcpy', undefined reference to `strlcat', undefined reference to `strtok_r'

我用谷歌搜索,发现我需要使用<bsd/string.h>. 但我发现资源仅用于为 linux 安装 libbsd。

谁能告诉我如何为 Windows 安装 bsd

标签: cstringwindows

解决方案


不幸的是,目前还没有 libbsd 到 Windows 的官方端口。您的选择是:

  1. strl*用标准化(但有些劣质)strn*函数(如strncpy, strncat)替换非标准函数
  2. strl*用 Windows 的非标准_s函数(如strcpy_s, strcat_s, strtok_s)替换非标准函数
  3. libbsd-minimal安装声称适用于 Windows的非官方软件包(未经测试)
  4. 根据这个对 libbsd 的长期拉取请求,您自己在 MinGW 上构建和安装 libbsd

很可能,(2)让您最接近(基于 API 相似性),但可能需要您添加一些特定于平台的宏或实用程序代码以保持可移植性。


推荐阅读