Skip to content

Commit e47b3c5

Browse files
committed
use C99 for-loop var decl for sblist_iter
1 parent c1f80f4 commit e47b3c5

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

Makefile

+5-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ SRCS = $(sort $(wildcard src/*/*.c))
1515
OBJS = $(SRCS:.c=.o)
1616
LOBJS = $(OBJS:.o=.lo)
1717

18-
CFLAGS += -Os
18+
CFLAGS += -Os
19+
CFLAGS_REQ=-std=c99
20+
1921
#-ffreestanding -std=c99 -D_XOPEN_SOURCE=700 -pipe
2022
#LDFLAGS = -nostdlib -shared -fPIC -Wl,-e,_start -Wl,-Bsymbolic-functions
2123
INC = -I./include
@@ -31,6 +33,8 @@ ALL_LIBS = $(ULZ_LIBS)
3133

3234
-include config.mak
3335

36+
CFLAGS += $(CFLAGS_REQ)
37+
3438
all: $(ALL_LIBS)
3539

3640
install: $(ALL_LIBS:lib/%=$(DESTDIR)$(libdir)/%) $(ALL_INCLUDES:include/%=$(DESTDIR)$(includedir)/ulz/%) $(ALL_TOOLS:tools/%=$(DESTDIR)$(bindir)/%)

include/sblist.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ size_t sblist_insert_sorted(sblist* l, void* o, int (*compar)(const void *, cons
6161
#define __sblist_iterator_name __sblist_macro_concat(sblist_iterator, __COUNTER__)
6262

6363
// use with custom iterator variable
64-
#define sblist_iter_counter(LIST, ITER, PTR) size_t ITER; \
65-
for(ITER = 0; (PTR = sblist_get(LIST, ITER)), ITER < sblist_getsize(LIST); ITER++)
66-
64+
#define sblist_iter_counter(LIST, ITER, PTR) \
65+
for(size_t ITER = 0; (PTR = sblist_get(LIST, ITER)), ITER < sblist_getsize(LIST); ITER++)
66+
6767
// use with custom iterator variable, which is predeclared
6868
#define sblist_iter_counter2(LIST, ITER, PTR) \
6969
for(ITER = 0; (PTR = sblist_get(LIST, ITER)), ITER < sblist_getsize(LIST); ITER++)

0 commit comments

Comments
 (0)