Skip to content
forked from mikepb/endian.h

Portable endian conversion functions for C

Notifications You must be signed in to change notification settings

shaiku/endian.h

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

endian.h

This provides the endian conversion functions form endian.h on Windows, Linux, *BSD, and Mac OS X. You still need to use -std=gnu99 instead of -std=c99 for gcc. The functions might actually be macros. Functions: htobe16, htole16, be16toh, le16toh, htobe32, htole32, be32toh, le32toh, htobe64, htole64, be64toh, le64toh.

The implementation was written by Mathias Panzenböck and published in this Gist.

Install

Install with [clib(1)]:

clib install mikepb/endian.h

Usage

#include <stdint.h>
#include "endian.h"

uint32_t endian32(const uint32_t i) {
    return be32toh(i);
}

License

Public Domain

About

Portable endian conversion functions for C

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C++ 100.0%