const qualifier

Arthur Gold agold@bga.com
Fri Oct 1 00:00:00 GMT 1999


Robert Smith wrote:
> 
> I have a customer moving from Greenhills to GNU C. They have been using
> "const" as shown in the example below. GNU doesn't compile it. Is there any
> option available to allow them to compile the code as is? They want to avoid
> the time-consuming process of changing all their code if it is possible.
> 
> /* ==================================================================
>    This is a test program which does nothing.  Its only purpose
>    is to test the const qualifier.
>    ================================================================== */
> 
> #include <stdio.h>
> 
> main()
> {
>   int   loopCounter;
> 
>   const int NPOINTS = 10;
> 
>   float fun [NPOINTS] = { 3., 6., 11., 18., 27., 38., 51., 66., 83., 102. };
Using a `const' as an array size is not legal C code. C++, however,
permits it.
Try using g++.

HTH,
--ag

> 
>   for (loopCounter = 0;
>        loopCounter < NPOINTS;
>        loopCounter++)
>     {
>       printf("function = %f\n", fun [loopCounter]);
>     }
> }
> 
> -----
> Thank you,
> 
> Robert
> --
> Robert Smith
> Belobox Networks

-- 
Artie Gold, Austin, TX
mailto:agold@bga.com or mailto:agold@cs.utexas.edu
--
Pet peeve: "its" = belonging or pertaining to "it" | "it's" = "it is"


More information about the Gcc-help mailing list