Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C/C++ library for platform-independent binary file I/O

Tags:

c++

file

io

binary

I've been trying for months to find a small C or C++ library for platform-independent binary file I/O, that means endian swapping and with fixed size types.

I know that huge libraries like wxWidgets and Qt have them, and that languages like Java and C# also have them, but I'd prefer to use a small library instead of a huge framework.

like image 421
testtesttes Avatar asked Nov 28 '10 09:11

testtesttes


People also ask

Where can I find CPP libraries?

Usually, there is '/lib' folder on Windows or '/usr/lib' folder on Linux that contains all the libraries. Once the library is installed, the compiler and the linker know the path of the library to use, and the library is ready for use.

What is binary file in C?

A binary file is a file whose content is in a binary format consisting of a series of sequential bytes, each of which is eight bits in length. The content must be interpreted by a program or a hardware processor that understands in advance exactly how that content is formatted and how to read the data.

Is a lib file a binary?

Libraries can be binary code. In fact, most of the stuff in /lib is going to be libraries compiled to machine code. While things like cat are used in shell script like calls to code in libraries, they are not libraries in the FHS sense because they can be run by themselves.


2 Answers

How about Google Protocol Buffers?

The library includes bindings for C++, Java and Python.

like image 141
Alnitak Avatar answered Oct 13 '22 12:10

Alnitak


Have a look at Boost.Serialization

One of it's goals is "Data Portability - Streams of bytes created on one platform should be readable on any other."

There are also links to other libraries providing similar functionality.

like image 43
Palmik Avatar answered Oct 13 '22 12:10

Palmik