Skip to content

Commit a1891bd

Browse files
committed
Use zero variadic macro concatenation
GCCのエラーを消す必要がある: ```sh src/wcc/wcc.c:767:26: error: passing no argument for the '...' parameter of a variadic macro is a C23 extension [-Werror,-Wvariadic-macro-arguments-omitted] 767 | VERBOSE("### Exports\n"); | ^ ```
1 parent 1c3c225 commit a1891bd

5 files changed

Lines changed: 10 additions & 11 deletions

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ CC1_BE_DIR:=$(CC1_DIR)/backend
3535

3636
OPTIMIZE:=-O2 -g3
3737
CFLAGS:=-ansi -std=c11 -pedantic -MMD -Wall -Wextra -Werror -Wold-style-definition \
38-
-Wno-missing-field-initializers -Wno-empty-body \
38+
-Wno-missing-field-initializers -Wno-empty-body -Wno-variadic-macro-arguments-omitted \
3939
-D_DEFAULT_SOURCE $(OPTIMIZE) -I$(UTIL_DIR)
4040
ifneq ("$(NO_FLONUM)","")
4141
CFLAGS+=-D__NO_FLONUM

src/wcc/emit_wasm.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ static void emit_elems_section(EmitWasm *ew) {
445445
data_open_chunk(&elems_section);
446446

447447
// Enumerate imported functions.
448-
VERBOSES("### Indirect functions\n");
448+
VERBOSE("### Indirect functions\n");
449449
data_leb128(&elems_section, -1, 1); // num elem segments
450450
data_leb128(&elems_section, -1, 0); // segment flags
451451
data_push(&elems_section, OP_I32_CONST);
@@ -460,7 +460,7 @@ static void emit_elems_section(EmitWasm *ew) {
460460
data_leb128(&elems_section, -1, finfo->index); // elem function index
461461
}
462462
data_close_chunk(&elems_section, -1);
463-
VERBOSES("\n");
463+
VERBOSE("\n");
464464

465465
fputc(SEC_ELEM, ew->ofp);
466466
fwrite(elems_section.buf, elems_section.len, 1, ew->ofp);
@@ -526,7 +526,7 @@ static Vector *emit_data_section(EmitWasm *ew) {
526526
if (segments->len > 0) {
527527
reloc_data = new_vector();
528528

529-
VERBOSES("### Data\n");
529+
VERBOSE("### Data\n");
530530
DataStorage datasec;
531531
data_init(&datasec);
532532
data_open_chunk(&datasec);
@@ -558,7 +558,7 @@ static Vector *emit_data_section(EmitWasm *ew) {
558558
}
559559
}
560560
data_close_chunk(&datasec, -1);
561-
VERBOSES("\n");
561+
VERBOSE("\n");
562562

563563
fputc(SEC_DATA, ew->ofp);
564564
fwrite(datasec.buf, datasec.len, 1, ew->ofp);

src/wcc/traverse.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,7 +1042,7 @@ static inline void assign_symbol_index(void) {
10421042

10431043
static inline void assign_function_index(void) {
10441044
// Enumerate functions.
1045-
VERBOSES("### Functions\n");
1045+
VERBOSE("### Functions\n");
10461046
const Name *name;
10471047
FuncInfo *finfo;
10481048
int32_t index = 0;
@@ -1057,7 +1057,7 @@ static inline void assign_function_index(void) {
10571057
VERBOSE("%2d: %.*s%s\n", finfo->index, NAMES(name), k == 0 ? " (import)" : "");
10581058
}
10591059
}
1060-
VERBOSES("\n");
1060+
VERBOSE("\n");
10611061
}
10621062

10631063
static inline void assign_data_address(void) {

src/wcc/wcc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -764,12 +764,12 @@ int main(int argc, char *argv[]) {
764764
add_inc_path(INC_AFTER, JOIN_PATHS(root, "include"));
765765
}
766766

767-
VERBOSES("### Exports\n");
767+
VERBOSE("### Exports\n");
768768
const Name *name;
769769
for (int it = 0; (it = table_iterate(opts.exports, it, &name, NULL)) != -1; ) {
770770
VERBOSE("%.*s\n", NAMES(name));
771771
}
772-
VERBOSES("\n");
772+
VERBOSE("\n");
773773

774774
if (opts.out_type >= OutExecutable) {
775775
vec_push(opts.lib_paths, JOIN_PATHS(root, "lib"));

src/wcc/wcc.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,7 @@ extern Vector *tables; // <TableInfo*>
199199
extern Vector *init_funcs; // <Function*>
200200
extern int compile_unit_flag;
201201

202-
#define VERBOSES(str) do { if (verbose) printf("%s", str); } while (0)
203-
#define VERBOSE(fmt, ...) do { if (verbose) printf(fmt, __VA_ARGS__); } while (0)
202+
#define VERBOSE(fmt, ...) do { if (verbose) printf(fmt __VA_OPT__(,) __VA_ARGS__); } while (0)
204203

205204
uint32_t get_indirect_function_index(const Name *name);
206205
GVarInfo *register_gvar_info(const Name *name, VarInfo *varinfo);

0 commit comments

Comments
 (0)