mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-22 19:22:05 +00:00
Build everything as C++ (#1176)
This commit is contained in:
@@ -9,9 +9,9 @@
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "asm/lexer.h"
|
||||
#include "asm/lexer.hpp"
|
||||
|
||||
#include "linkdefs.h"
|
||||
#include "linkdefs.hpp"
|
||||
|
||||
struct FileStackNode {
|
||||
struct FileStackNode *parent; // Pointer to parent node, for error reporting
|
||||
@@ -7,9 +7,9 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "asm/warning.h"
|
||||
#include "asm/warning.hpp"
|
||||
|
||||
#include "helpers.h"
|
||||
#include "helpers.hpp"
|
||||
|
||||
struct MacroArgs;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "helpers.h"
|
||||
#include "helpers.hpp"
|
||||
|
||||
extern bool haltNop;
|
||||
extern bool warnOnHaltNop;
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "linkdefs.h"
|
||||
#include "linkdefs.hpp"
|
||||
|
||||
struct Expression;
|
||||
struct FileStackNode;
|
||||
@@ -6,7 +6,7 @@
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "linkdefs.h"
|
||||
#include "linkdefs.hpp"
|
||||
|
||||
#define MAXRPNLEN 1048576
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "linkdefs.h"
|
||||
#include "platform.h" // NONNULL
|
||||
#include "linkdefs.hpp"
|
||||
#include "platform.hpp" // NONNULL
|
||||
|
||||
extern uint8_t fillByte;
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "asm/section.h"
|
||||
#include "asm/section.hpp"
|
||||
|
||||
#include "platform.h" // MIN_NB_ELMS
|
||||
#include "platform.hpp" // MIN_NB_ELMS
|
||||
|
||||
#define MAXSYMLEN 255
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#ifndef WARNING_H
|
||||
#define WARNING_H
|
||||
|
||||
#include "helpers.h"
|
||||
#include "helpers.hpp"
|
||||
|
||||
extern unsigned int nbErrors;
|
||||
|
||||
@@ -77,7 +77,7 @@ void warning(enum WarningID id, char const *fmt, ...) format_(printf, 2, 3);
|
||||
* It is also used when the assembler goes into an invalid state (for example,
|
||||
* when it fails to allocate memory).
|
||||
*/
|
||||
_Noreturn void fatalerror(char const *fmt, ...) format_(printf, 1, 2);
|
||||
[[noreturn]] void fatalerror(char const *fmt, ...) format_(printf, 1, 2);
|
||||
|
||||
/*
|
||||
* Used for errors that make it impossible to assemble correctly, but don't
|
||||
@@ -3,21 +3,17 @@
|
||||
#ifndef RGBDS_ERROR_H
|
||||
#define RGBDS_ERROR_H
|
||||
|
||||
#include "helpers.h"
|
||||
#include "platform.h"
|
||||
#include "helpers.hpp"
|
||||
#include "platform.hpp"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void warn(char const NONNULL(fmt), ...) format_(printf, 1, 2);
|
||||
void warnx(char const NONNULL(fmt), ...) format_(printf, 1, 2);
|
||||
|
||||
_Noreturn void err(char const NONNULL(fmt), ...) format_(printf, 1, 2);
|
||||
_Noreturn void errx(char const NONNULL(fmt), ...) format_(printf, 1, 2);
|
||||
[[noreturn]] void err(char const NONNULL(fmt), ...) format_(printf, 1, 2);
|
||||
[[noreturn]] void errx(char const NONNULL(fmt), ...) format_(printf, 1, 2);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // RGBDS_ERROR_H
|
||||
@@ -26,9 +26,7 @@
|
||||
#ifndef RGBDS_EXTERN_GETOPT_H
|
||||
#define RGBDS_EXTERN_GETOPT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern char *musl_optarg;
|
||||
extern int musl_optind, musl_opterr, musl_optopt, musl_optreset;
|
||||
@@ -47,8 +45,6 @@ int musl_getopt_long_only(int argc, char **argv, char const *optstring,
|
||||
#define required_argument 1
|
||||
#define optional_argument 2
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -16,8 +16,8 @@
|
||||
#include <string_view>
|
||||
#include <variant>
|
||||
|
||||
#include "helpers.h"
|
||||
#include "platform.h"
|
||||
#include "helpers.hpp"
|
||||
#include "platform.hpp"
|
||||
|
||||
#include "gfx/main.hpp"
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "helpers.h"
|
||||
#include "helpers.hpp"
|
||||
|
||||
#include "gfx/rgba.hpp"
|
||||
|
||||
|
||||
@@ -3,11 +3,6 @@
|
||||
#ifndef HELPERS_H
|
||||
#define HELPERS_H
|
||||
|
||||
// Of course, MSVC does not support C11, so no _Noreturn there...
|
||||
#ifdef _MSC_VER
|
||||
#define _Noreturn __declspec(noreturn)
|
||||
#endif
|
||||
|
||||
// Ideally, we'd use `__has_attribute` and `__has_builtin`, but these were only introduced in GCC 9
|
||||
#ifdef __GNUC__ // GCC or compatible
|
||||
#define format_(archetype, str_index, first_arg) \
|
||||
@@ -24,8 +19,8 @@
|
||||
#define format_(archetype, str_index, first_arg)
|
||||
#define attr_(...)
|
||||
// This seems to generate similar code to __builtin_unreachable, despite different semantics
|
||||
// Note that executing this is undefined behavior (declared _Noreturn, but does return)
|
||||
static inline _Noreturn void unreachable_(void) {}
|
||||
// Note that executing this is undefined behavior (declared [[noreturn]], but does return)
|
||||
[[noreturn]] static inline void unreachable_(void) {}
|
||||
#endif
|
||||
|
||||
// Use builtins whenever possible, and shim them otherwise
|
||||
@@ -6,7 +6,7 @@
|
||||
#include <tuple>
|
||||
#include <utility>
|
||||
|
||||
#include "platform.h" // __PRETTY_FUNCTION__
|
||||
#include "platform.hpp" // __PRETTY_FUNCTION__
|
||||
|
||||
template<typename... Ts>
|
||||
static inline void report() {
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "helpers.h"
|
||||
#include "linkdefs.h"
|
||||
#include "helpers.hpp"
|
||||
#include "linkdefs.hpp"
|
||||
|
||||
// Variables related to CLI options
|
||||
extern bool isDmgMode;
|
||||
@@ -61,7 +61,7 @@ void warning(struct FileStackNode const *where, uint32_t lineNo,
|
||||
void error(struct FileStackNode const *where, uint32_t lineNo,
|
||||
char const *fmt, ...) format_(printf, 3, 4);
|
||||
|
||||
_Noreturn void fatal(struct FileStackNode const *where, uint32_t lineNo,
|
||||
[[noreturn]] void fatal(struct FileStackNode const *where, uint32_t lineNo,
|
||||
char const *fmt, ...) format_(printf, 3, 4);
|
||||
|
||||
/*
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "link/section.h"
|
||||
#include "link/section.hpp"
|
||||
|
||||
/*
|
||||
* Registers a section for output.
|
||||
@@ -7,9 +7,9 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "link/section.h"
|
||||
#include "link/section.hpp"
|
||||
|
||||
#include "linkdefs.h"
|
||||
#include "linkdefs.hpp"
|
||||
|
||||
struct Assertion {
|
||||
struct Patch patch;
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "linkdefs.h"
|
||||
#include "linkdefs.hpp"
|
||||
|
||||
extern FILE * linkerScript;
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "link/main.h"
|
||||
#include "link/main.hpp"
|
||||
|
||||
#include "linkdefs.h"
|
||||
#include "linkdefs.hpp"
|
||||
|
||||
struct FileStackNode;
|
||||
struct Section;
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "linkdefs.h"
|
||||
#include "linkdefs.hpp"
|
||||
|
||||
struct FileStackNode;
|
||||
|
||||
@@ -49,15 +49,17 @@
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
// MSVC doesn't support `[static N]` for array arguments from C99 or C11
|
||||
#ifdef _MSC_VER
|
||||
# define MIN_NB_ELMS(N)
|
||||
# define ARR_QUALS(...)
|
||||
# define NONNULL(ptr) *ptr
|
||||
// C++ doesn't support `[static N]` for array arguments from C99 or C11
|
||||
#define MIN_NB_ELMS(N) // static (N)
|
||||
#define ARR_QUALS(...) // __VA_ARGS__
|
||||
#define NONNULL(ptr) *ptr // ptr[static 1]
|
||||
#define restrict
|
||||
|
||||
// C++ doesn't support designated array initializers, but they're a gcc extension
|
||||
#ifdef __GNUC__
|
||||
# define AT(index) [index] =
|
||||
#else
|
||||
# define MIN_NB_ELMS(N) static (N)
|
||||
# define ARR_QUALS(...) __VA_ARGS__
|
||||
# define NONNULL(ptr) ptr[static 1]
|
||||
# define AT(index)
|
||||
#endif
|
||||
|
||||
// MSVC uses a different name for O_RDWR, and needs an additional _O_BINARY flag
|
||||
@@ -3,9 +3,7 @@
|
||||
#ifndef EXTERN_VERSION_H
|
||||
#define EXTERN_VERSION_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define PACKAGE_VERSION_MAJOR 0
|
||||
#define PACKAGE_VERSION_MINOR 6
|
||||
@@ -13,8 +11,6 @@ extern "C" {
|
||||
|
||||
char const *get_package_version_string(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // EXTERN_VERSION_H
|
||||
Reference in New Issue
Block a user