Fixing build problems due to endian.h

Have to define _DEFAULT_SOURCE before you can use the endian
conversion functions.  As most standard library headers use
features.h, and _DEFAULT_SOURCE must be defined before features.h is
included, we have to include base.h before other headers.
This commit is contained in:
2024-04-12 17:32:58 +06:30
parent a8a2c50a8f
commit 72585772ef
4 changed files with 9 additions and 8 deletions

View File

@@ -10,11 +10,10 @@
* Description: Implementation of basic library functions * Description: Implementation of basic library functions
*/ */
#include <endian.h>
#include <string.h>
#include "./base.h" #include "./base.h"
#include <string.h>
hword convert_bytes_to_hword(byte *bytes) hword convert_bytes_to_hword(byte *bytes)
{ {
hword be_h = 0; hword be_h = 0;

View File

@@ -13,6 +13,8 @@
#ifndef BASE_H #ifndef BASE_H
#define BASE_H #define BASE_H
#define _DEFAULT_SOURCE
#include <endian.h>
#include <stdint.h> #include <stdint.h>
/* Basic macros for a variety of uses. Quite self explanatory. */ /* Basic macros for a variety of uses. Quite self explanatory. */

View File

@@ -10,13 +10,13 @@
* Description: Implementation of bytecode for instructions * Description: Implementation of bytecode for instructions
*/ */
#include "./inst.h"
#include <assert.h> #include <assert.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "./inst.h"
const char *opcode_as_cstr(opcode_t code) const char *opcode_as_cstr(opcode_t code)
{ {
switch (code) switch (code)

View File

@@ -13,12 +13,12 @@
#ifndef INST_H #ifndef INST_H
#define INST_H #define INST_H
#include <stdio.h>
#include <stdlib.h>
#include <lib/base.h> #include <lib/base.h>
#include <lib/darr.h> #include <lib/darr.h>
#include <stdio.h>
#include <stdlib.h>
typedef enum typedef enum
{ {
OP_NOOP = 0, OP_NOOP = 0,