Horje
how to choose struct's endianness cpp Code Example
how to choose struct's endianness cpp
#include <stdio.h>
#include <stdint.h>

//The line bellow does the trick:
//__attribute__((packed, scalar_storage_order("big-endian")))
struct __attribute__((packed, scalar_storage_order("big-endian"))) mystruct {
    uint16_t a;
    uint32_t b;
    uint64_t c;
};


int main(int argc, char** argv) {
    struct mystruct bar = {.a = 0xaabb, .b = 0xff0000aa, .c = 0xabcdefaabbccddee};

    FILE *f = fopen("out.bin", "wb");
    size_t written = fwrite(&bar, sizeof(struct mystruct), 1, f);
    fclose(f);
}




Cpp

Related
convert c code to c++ Code Example convert c code to c++ Code Example
write c++ code using glbegin and gland() function Code Example write c++ code using glbegin and gland() function Code Example
https://www.codegrepper.com Code Example https://www.codegrepper.com Code Example
convert c++ to python online Code Example convert c++ to python online Code Example
script hack blox fruti Code Example script hack blox fruti Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
12