加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c – 支持linux / types.h OSX

发布时间:2020-12-16 06:01:52 所属栏目:百科 来源:网络整理
导读:我正在尝试使用OSX交叉编译应用程序.但是,当我编译我得到以下内容 fatal error: 'linux/types.h' file not found 当我更改为sys / types.h,现在我得到… error: unknown type name '__s32' unknown type name '__u8' unknown type name '__u16' etc 有人可以
我正在尝试使用OSX交叉编译应用程序.但是,当我编译我得到以下内容
fatal error: 'linux/types.h' file not found

当我更改为sys / types.h,现在我得到…

error: unknown type name '__s32'
 unknown type name '__u8'
 unknown type name '__u16'
 etc

有人可以帮我解决这个问题吗?

解决方法

显然,一个Linux特定的头文件不会出现在MacOS / X下,这不是基于Linux的.

解决问题的最简单的办法是通过你的程序来替换所有的实例

#include "linux/types.h"

有了这个:

#include "my_linux_types.h"

…并写入一个名为my_linux_types.h的新头文件,并将其添加到您的项目中;它会看起来像这样:

#ifndef my_linux_types_h
#define my_linux_types_h

#ifdef __linux__
# include "linux/types.h"
#else
# include <stdint.h>
typedef int32_t __s32;
typedef uint8_t __u8;
typedef uint16_t __u16;
[... and so on for whatever other types your program uses ...]
#endif

#endif

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读