|
From: Hans P. S. <hse...@c2...> - 2012-07-19 13:27:35
|
On Thursday 19 July 2012 15:23:34 Daniele Forsi wrote:
> 2012/7/19 Hans Petter Selasky:
> > Declaring variables inside a for loop is a C++ feature, not a C feature
> > ??
>
> it's C++ and C99 section "6.8.5 Iteration statements"
>
> > At least the compiler over here: cc (GCC) 4.2.1 20070831 patched
> > [FreeBSD]
> >
> > Complained.
>
> only on that line?
> I'm asking because also declaring the variable in the middle of the
> code is a C++ and C99 feature and similar code is used in several
> places:
>
> $ grep "for (" . -rn --include=*.c | grep int
> ./libgtkpod/gtkpod_app_iface.c:640: for (gint i = 0; i <
> g_list_length(gp_iface->track_commands); ++i) {
> ./plugins/sorttab_display/sorttab_widget.c:336: for (gint i = 0; i
> < ST_CAT_NUM; ++i) {
> ./plugins/sorttab_display/display_sorttabs.c:69: for (gint i = 0; i
> < sort_tab_total; ++i) {
> ./plugins/clarity/clarity_canvas.c:598: for (gint i = 0; i <
> g_list_length(priv->covers); ++i) {
> ./plugins/playlist_display/display_playlists.c:1073: for (gint i =
> 0; i < g_list_length(playlists); ++i) {
This is when building with cmake:
make
Merging translations into gtkpod.desktop.
[ 0%] Built target desktopfile
Scanning dependencies of target gtkpod
[ 2%] Building C object CMakeFiles/gtkpod.dir/libgtkpod/gtkpod_app_iface.c.o
libgtkpod/gtkpod_app_iface.c: In function 'gtkpod_execute_track_command':
libgtkpod/gtkpod_app_iface.c:640: error: 'for' loop initial declaration used
outside C99 mode
*** Error code 1
--HPS
|