Web lists-archives.com

Re: compile problem on older program




On Sat, Oct 28, 2017 at 09:29:16AM -0700, Fred wrote:
> Hello,
> 
> I need to compile an older program and have a compile error.  How can I
> resolve this?  Unfortunately I am not a C programmer although I do assembler
> programming.
> 
> Here is the output of make:
> 
> making all in ./src...
> make[1]: Entering directory '/opt/pcb-1.6.3p/src'
> gcc -m32 -g -O2 -fno-strict-aliasing         -Dlinux -D__i386__
> -D_POSIX_C_SOURCE=199309L                 -D_POSIX_SOURCE -D_XOPEN_SOURCE
> -D_BSD_SOURCE -D_SVID_SOURCE
> -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DFUNCPROTO=15 -DNARROWPROTO
> -DRELEASE=\"1.6.3\" -DPCBLIBDIR=\"/home/cad/lib/pcb\"  -DBTNMOD=\"Mod1\"
> -DFONTFILENAME=\"default_font\"  -DLIBRARYFILENAME=\"pcblib\"
> -DGNUM4=\"/usr/bin/m4\"  -DHAS_ATEXIT  -DHAS_REGEX      -c -o dev_rs274x.o
> dev_rs274x.c
> dev_rs274x.c: In function â??GBX_PrintPolygonâ??:
> dev_rs274x.c:821:13: error: invalid storage class for function
> â??isRectangleâ??
>   static int isRectangle(PolygonTypePtr Ptr);
>              ^
> <builtin>: recipe for target 'dev_rs274x.o' failed
> make[1]: *** [dev_rs274x.o] Error 1
> make[1]: Leaving directory '/opt/pcb-1.6.3p/src'
> Makefile:1071: recipe for target 'all' failed
> make: *** [all] Error 2
> 
The error is pointing to a function declaration.
> 
> The source:
> 
This source is for the function definition/implementation.  We don't
even know if this is in the same source file as the line that caused the
error (which may or may not be relevant).

> /* ----------------------------------------------------------------------
>  * Checks a four-point polygon to see if it's a rectangle.
>  * Tick off pairs of X & Y coords; if we get four matches,
>  * we have a rectangle.
>  */
> static int isRectangle(PolygonTypePtr Ptr)
> {
>     Cardinal i, j;
>     int matches = 0;
> 
>         if (Ptr->PointN != 4)
>        return(0);
> 
>         for (i=0; i<4; i++)
>            for (j = i+1; j<4; j++) {
>           if (Ptr->Points[i].X == Ptr->Points[j].X)
>              matches++;
> 
>           if (Ptr->Points[i].Y == Ptr->Points[j].Y)
>              matches++;
>        }
> 
>         if (matches == 4)
>        return(1);
>     else
>        return(0);
>  }
> 
> 
It is difficult to say, but this might explain it:
https://stackoverflow.com/questions/11706868/confusion-about-static-function-pointer-in-c

You may need to remove the static keyword from the declaration.

If you could provide complete sources (or a link to them) then perhaps
someone could provide a more definitive answer.

Regards,

-Roberto

-- 
Roberto C. Sánchez