On 07/19, Stefan Beller wrote:
> This is another test balloon to see if we get complaints from people
> whose compilers do not support variables scoped to for loops.
> 
> This part of the code base was chosen as it is very old code that does
> not change often, such that a potential revert is easy.
> 
> Signed-off-by: Stefan Beller <sbel...@google.com>
> ---
> 
> This is a rather aggressive test ballon, my compiler needed some
> good arguments to accept the new world order:
> 
> object.c: In function ‘object_array_remove_duplicates’:
> object.c:404:2: error: ‘for’ loop initial declarations are only allowed in 
> C99 mode
>   for (unsigned src = 0; src < nr; src++) {
>   ^
> object.c:404:2: note: use option -std=c99 or -std=gnu99 to compile your code
> 
> Using -std=c99 works for me.

This would need a change to the makefile then wouldn't it?

> 
> Thanks,
> Stefan
> 
>  object.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/object.c b/object.c
> index f818777412..af26ee2fbc 100644
> --- a/object.c
> +++ b/object.c
> @@ -397,11 +397,11 @@ static int contains_name(struct object_array *array, 
> const char *name)
>  
>  void object_array_remove_duplicates(struct object_array *array)
>  {
> -     unsigned nr = array->nr, src;
> +     unsigned nr = array->nr;
>       struct object_array_entry *objects = array->objects;
>  
>       array->nr = 0;
> -     for (src = 0; src < nr; src++) {
> +     for (unsigned src = 0; src < nr; src++) {
>               if (!contains_name(array, objects[src].name)) {
>                       if (src != array->nr)
>                               objects[array->nr] = objects[src];
> -- 
> 2.14.0.rc0.3.g6c2e499285
> 

-- 
Brandon Williams

Reply via email to