From 3c17cff77ccee8c90d5ffea02b7cc8f7e828a4b8 Mon Sep 17 00:00:00 2001 From: Michael Forney <mforney@mforney.org> Date: Fri, 23 Apr 2021 12:49:55 -0700 Subject: Make some static data const --- cc.h | 2 +- configure | 14 +++++++------- qbe.c | 2 +- targ.c | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/cc.h b/cc.h index 8143528..b47853b 100644 --- a/cc.h +++ b/cc.h @@ -437,7 +437,7 @@ struct target { int signedchar; }; -extern struct target *targ; +extern const struct target *targ; void targinit(const char *); diff --git a/configure b/configure index cea7aca..526da31 100755 --- a/configure +++ b/configure @@ -129,10 +129,10 @@ test "$DEFAULT_DYNAMIC_LINKER" && linkflags=$linkflags' "--dynamic-linker", "'$D printf "creating config.h... " cat >config.h <<EOF -static char target[] = "$target"; -static char *startfiles[] = {$startfiles}; -static char *endfiles[] = {$endfiles}; -static char *preprocesscmd[] = { +static const char target[] = "$target"; +static const char *const startfiles[] = {$startfiles}; +static const char *const endfiles[] = {$endfiles}; +static const char *const preprocesscmd[] = { "$DEFAULT_PREPROCESSOR", "-P", /* clear preprocessor GNU C version */ @@ -149,9 +149,9 @@ static char *preprocesscmd[] = { "-D", "__attribute__(x)=", "-D", "__extension__=", $defines}; -static char *codegencmd[] = {"$DEFAULT_QBE"}; -static char *assemblecmd[] = {"$DEFAULT_ASSEMBLER"}; -static char *linkcmd[] = {"$DEFAULT_LINKER", $linkflags}; +static const char *const codegencmd[] = {"$DEFAULT_QBE"}; +static const char *const assemblecmd[] = {"$DEFAULT_ASSEMBLER"}; +static const char *const linkcmd[] = {"$DEFAULT_LINKER", $linkflags}; EOF echo done diff --git a/qbe.c b/qbe.c index 91b88fd..5d7c88a 100644 --- a/qbe.c +++ b/qbe.c @@ -209,7 +209,7 @@ functemp(struct func *f, struct value *v, struct repr *repr) v->repr = repr; } -static const char *instname[] = { +static const char *const instname[] = { #define OP(op, name) [op] = name, #include "ops.h" #undef OP diff --git a/targ.c b/targ.c index 6ffef9e..2859975 100644 --- a/targ.c +++ b/targ.c @@ -3,9 +3,9 @@ #include "util.h" #include "cc.h" -struct target *targ; +const struct target *targ; -static struct target alltargs[] = { +static const struct target alltargs[] = { { .name = "x86_64", .typewchar = &typeint, -- cgit v1.2.3