seleznevae / libfort

C/C++ library to create formatted ASCII tables for console applications
MIT License
493 stars 65 forks source link

Not more than 15 columns supported #47

Closed ashishpatel1992 closed 4 years ago

ashishpatel1992 commented 4 years ago

I am not able to add more than 15 columns as it throws compiler warning and segmentation fault on running it.

warning: passing argument 2 of ‘ft_u8nwrite_ln’ makes integer from pointer without a cast [-Wint-conversion]
 Рейтинг","Рейтинг","Рейтинг","Рейтинг","Рейтинг","Рейтинг","Рейтинг","Рейтинг", "Ранг", "Название", "s","x");
                                                                                                                                                                             ^
util/libfort/fort.h:187:23: note: in definition of macro ‘FT_EXPAND_’
 #define FT_EXPAND_(x) x
                       ^
util/libfort/fort.h:189:16: note: in expansion of macro ‘FT_NARGS_IMPL_’
     FT_EXPAND_(FT_NARGS_IMPL_(__VA_ARGS__,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0))
                ^~~~~~~~~~~~~~
util/libfort/fort.h:1011:28: note: in expansion of macro ‘FT_PP_NARG_’
     (ft_u8nwrite_ln(table, FT_PP_NARG_(__VA_ARGS__), __VA_ARGS__))
                            ^~~~~~~~~~~
testprogram.c:72:5: note: in expansion of macro ‘ft_u8write_ln’
     ft_u8write_ln(table, "Ранг", "Название", "Год", "Рейтинг","Рейтинг","Рейтинг","Рейтинг","Рейтинг","Рейтинг","Рейтинг","Рейтинг","Рейтинг", "Ранг", "Название", "s","x");
     ^~~~~~~~~~~~~
In file included from testprogram.c:12:0:
util/libfort/fort.c:3680:5: note: expected ‘size_t {aka long unsigned int}’ but argument is of type ‘char *’
 int ft_u8nwrite_ln(ft_table_t *table, size_t n, const void *cell_content, ...)warning: passing argument 2 of ‘ft_u8nwrite_ln’ makes integer from pointer without a cast [-Wint-conversion]
 Рейтинг","Рейтинг","Рейтинг","Рейтинг","Рейтинг","Рейтинг","Рейтинг","Рейтинг", "Ранг", "Название", "s","x");
                                                                                                                                                                             ^
util/libfort/fort.h:187:23: note: in definition of macro ‘FT_EXPAND_’
 #define FT_EXPAND_(x) x
                       ^
util/libfort/fort.h:189:16: note: in expansion of macro ‘FT_NARGS_IMPL_’
     FT_EXPAND_(FT_NARGS_IMPL_(__VA_ARGS__,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0))
                ^~~~~~~~~~~~~~
util/libfort/fort.h:1011:28: note: in expansion of macro ‘FT_PP_NARG_’
     (ft_u8nwrite_ln(table, FT_PP_NARG_(__VA_ARGS__), __VA_ARGS__))
                            ^~~~~~~~~~~
testprogram.c:72:5: note: in expansion of macro ‘ft_u8write_ln’
     ft_u8write_ln(table, "Ранг", "Название", "Год", "Рейтинг","Рейтинг","Рейтинг","Рейтинг","Рейтинг","Рейтинг","Рейтинг","Рейтинг","Рейтинг", "Ранг", "Название", "s","x");
     ^~~~~~~~~~~~~
In file included from testprogram.c:12:0:
util/libfort/fort.c:3680:5: note: expected ‘size_t {aka long unsigned int}’ but argument is of type ‘char *’
 int ft_u8nwrite_ln(ft_table_t *table, size_t n, const void *cell_content, ...)
seleznevae commented 4 years ago

Hi! Currently there is a limit on the number of arguments passed to ft_u8write_ln. ft_u8write_ln is a macro, and extending the number of arguments is done manually. So obviously there should be some limit. At the moment it is 16. Please note that ft_u8write_ln is a utility macros around ft_u8nwrite_ln. And the only thing ft_u8write_ln does is checking arguments and counting their number. If you have a lot of arguments you can just use function ft_u8nwrite_ln:

// n below - number of arguments
ft_u8nwrite_ln(table, n, .../*here goes arguments*/);

ft_u8nwrite_ln doesn't have limitations on the number of arguments. But you'll have to provide number of arguments for this function yourself.