Skip to content

Instantly share code, notes, and snippets.

@adammw
Created April 22, 2024 04:22
Show Gist options
  • Save adammw/22fbc0c16e40cfd1241a874e3914a89d to your computer and use it in GitHub Desktop.
Save adammw/22fbc0c16e40cfd1241a874e3914a89d to your computer and use it in GitHub Desktop.
#ifdef __APPLE__
#include <machine/endian.h>
#include <libkern/OSByteOrder.h>
#define le32toh(x) OSSwapLittleToHostInt32(x)
#else
#include <endian.h>
#endif
#include "main.h"
inline int32_t decode_int32(int32_t source) {
return le32toh(source);
}
int sample_func() {
int ret = decode_int32(0xff00);
return ret;
}
package main
// #cgo CFLAGS: -I${SRCDIR}/
// #include "main.h"
// #include <stdint.h>
import "C"
import "fmt"
func main() {
res := C.sample_func()
fmt.Printf("result=%d\n", res)
}
#ifndef MAIN_H
#define MAIN_H
int sample_func();
#endif // MAIN_H
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment