Reputation: 15778
I'm trying to do a simple sprintf
like this:
snprintf(dest, maxlen_dest, "%'lu", along);
Note the quote: '
in the string.
This means (according to the manual):
' For decimal conversion (i, d, u, f, F, g, G) the output is to be grouped with thousands’ grouping characters if the locale information indicates any. Note that many versions of gcc(1) cannot parse this option and will issue a warning. SUSv2 does not include %'F.
So when I compile, I get this warning:
../common/utils.c:29: warning: ISO C does not support the ''' printf flag
../common/utils.c:29: warning: ISO C does not support the ''' printf flag
So, my question is: is there a function that "supports the ''' printf flag" I could use?
I want my output to be like:
51 254 234
1 424 000
...
...
...
Here's my Makefile (in case there's some options I should modify):
CC = gcc
# -g = all debug options
CFLAGS = -g -I../common -W -Wall -pedantic -std=c99
OBJECTS = o/main.o o/opts.o o/verif_liens_bidirectionnels.o o/ecriture.o o/plugin_utils.o o/plugin_algo_groupes.o ../common/o/cell.o ../common/o/utils.o ../common/o/verif.o ../common/o/lecture.o
gen : $(OBJECTS)
$(CC) -o gen $(OBJECTS) $(CFLAGS) -lm -lgd -lz
o/main.o : main.c
$(CC) -o $@ -c main.c $(CFLAGS)
o/opts.o : opts.c opts.h
$(CC) -o $@ -c opts.c $(CFLAGS)
o/verif_liens_bidirectionnels.o : verif_liens_bidirectionnels.c verif_liens_bidirectionnels.h
$(CC) -o $@ -c verif_liens_bidirectionnels.c $(CFLAGS)
o/ecriture.o : ecriture.c ecriture.h
$(CC) -o $@ -c ecriture.c $(CFLAGS)
o/plugin_utils.o : plugin_utils.c plugin_utils.h
$(CC) -o $@ -c plugin_utils.c $(CFLAGS)
o/plugin_algo_groupes.o : plugin_algo_groupes.c plugin_algo_groupes.h
$(CC) -o $@ -c plugin_algo_groupes.c $(CFLAGS)
../common/o/cell.o : ../common/cell.c ../common/cell.h
$(CC) -o $@ -c ../common/cell.c $(CFLAGS)
../common/o/utils.o : ../common/utils.c ../common/utils.h
$(CC) -o $@ -c ../common/utils.c $(CFLAGS)
../common/o/verif.o : ../common/verif.c ../common/verif.h
$(CC) -o $@ -c ../common/verif.c $(CFLAGS)
../common/o/lecture.o : ../common/lecture.c ../common/lecture.h
$(CC) -o $@ -c ../common/lecture.c $(CFLAGS)
clean :
rm $(OBJECTS)
Upvotes: 2
Views: 458
Reputation: 169583
You could add
../common/o/utils.o : CFLAGS := $(filter-out -pedantic,$(CFLAGS))
to the makefile, which should suppress the warning for the specific file.
If you don't want to rely on non-standard libc extensions, you'll have to implement the functionality yourself...
Upvotes: 2