1.结构体sizeof问题
Linux支持指定结构体比特字段,Windows不支持指定结构体比特字段
struct index { long long start = 0; long long end = 0; unsigned long long ix = 0; short segment = 0; unsigned short t : 2; unsigned long long seq : (64 - 18); // pack with segment and t to stay in 32 bytes index() : t(0), seq(0) { } }; long long index_size = sizeof( index );
Linux下index_size值为32,Windows下index_size值为40
参考:https://blog.csdn.net/weixin_42365422/article/details/117242430
2.fwrite写如0X0A时自动添加0X0D
Linux没有此问题,Windows()会有此问题
如果我们查看十六进制时,会发现 `0D,0A ,00,00,00`莫名奇妙的多了一个`0D`。
原因是fwrite 在以文本方式写文件时,碰到`0X0A`,会自动在前面加上`0X0D`,以够成回车换行符。
FILE *fp = fopen("1.txt","w+");
改为
FILE *fp = fopen("1.txt","w+b");
参考:https://blog.csdn.net/shen_001/article/details/8750748
标签:总结,index,00,Windows,unsigned,long,开发,C++,size From: https://www.cnblogs.com/gispathfinder/p/18084913