| 注册
请输入搜索内容

热门搜索

Java Linux MySQL PHP JavaScript Hibernate jQuery Nginx
cf46d
10年前发布

将二进制文件加到C源码中的工具包:incbin.bat

有时你需要将二进制数据嵌入至C / C++程序。 INCBIN是一个跨平台的工具,刚好用来做到这一点。不像其他的解决方案,INCBIN是使用操作系统已经搭载的部件,所以不需要安装第三方工具。它是跨平台的,并且同样适用于Windows和UNIX系统。

Example usage:

Windows:      incbin.bat myfile.bin output.h foo  UNIX:         sh incbin.bat myfile.bin output.h foo

(where 'foo' is the C symbol name you want the data stored in)

Further usage

Here's an example showing how to callincbinfrom a Makefile:

all : foo.h    SCRIPTSHELL := $(if $(findstring $(OS),Windows_NT),cmd /c,sh)    foo.h : test.png      $(SCRIPTSHELL) incbin.bat $< $@ foo

Output format

Here's an example of the kind of output you get:

incbin.bat test.bin foodata.h foo

/* Generated by incbin */    #include <stddef.h>    const unsigned char foo_data[] = {  /*00000000*/ 0x40,0x65,0x63,0x68,0x6F,0x20,0x6F,0x66,0x66,0x0D,0x0A,0x22,0x43,0x3A,0x5C,0x50,  /*00000010*/ 0x72,0x6F,0x67,0x72,0x61,0x6D,0x20,0x46,0x69,0x6C,0x65,0x73,0x20,0x28,0x78,0x38,  /*00000020*/ 0x36,0x29,0x5C,0x4D,0x69,0x63,0x72,0x6F,0x73,0x6F,0x66,0x74,0x20,0x56,0x69,0x73,  /*00000030*/ 0x75,0x61,0x6C,0x20,0x53,0x74,0x75,0x64,0x69,0x6F,0x20,0x39,0x2E,0x30,0x5C,0x56,  /*00000040*/ 0x43,0x5C,0x62,0x69,0x6E,0x5C,0x76,0x63,0x76,0x61,0x72,0x73,0x33,0x32,0x2E,0x62,  /*00000050*/ 0x61,0x74,0x22,0x0D,0x0A  };    const size_t foo_size = sizeof(foo_data);

项目主页:http://www.open-open.com/lib/view/home/1422783944267


 本文由用户 cf46d 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
 转载本站原创文章,请注明出处,并保留原始链接、图片水印。
 本站是一个以用户分享为主的开源技术平台,欢迎各类分享!
 本文地址:https://www.open-open.com/lib/view/open1422783944267.html
C/C++开发 incbin.bat