[GRASS5] GRASS 5 and ANSI C

Markus,

You can use the -ansi flag to force gcc to support full ANSI
features and to disable non-ANSI features. If you then use
-pedantic the compiler will reject any code that is not ANSI
standard. The error.log will contain a list of uncompiled
code.
If you redirect stderr to a file during compilation then
that file will give more details about the violations.

It would be nice if there were some way to get gcc to
convert non-ansi code to ansi code. World peace and an end
to all famine and pestilence would be nice too.

Roger Miller

Hi developers,

Prof Giulio Antoniol (who published the clone detection
for GRASS:
http://mpa.itc.it/markus/grass_clones/index.html
) is also interested to perform some profiling analysis on
the GRASS code.
This helps to find out where/if time is spent/wasted in
loops etc. E.g. the
'gprof' tool calculates the amount of time spent in each
routine.

Later we'll probably add some code (locally at IRST) to
our GRASS version
and check for several days/weeks, which functions are used
and how time
consuming they are (to find potential areas for code
improvement).

But: For the analysis the GRASS code must be ANSI C. It
seems that
there is still some K&R code existing....
Since Giulio Antoniol is busy at time he asked me to
'stimulate' some
code conversion :slight_smile:

As I am not too confident with that, I would like to ask
- how we can identify K&R C coding style (any gcc
tricks?)
- how we can (partially automated) update to ANSI C (ok,
newbie question)?

Thanks,

Markus

_______________________________________________
grass5 mailing list
grass5@grass.itc.it
http://grass.itc.it/mailman/listinfo/grass5

On Thu, Oct 03, 2002 at 10:14:06AM -0700, roger wrote:

Markus,

You can use the -ansi flag to force gcc to support full ANSI
features and to disable non-ANSI features. If you then use
-pedantic the compiler will reject any code that is not ANSI
standard. The error.log will contain a list of uncompiled
code.

Generally speaking, K&R C is perfectly valid ANSI C89/90.
So, -ansi -pendantic might not change much. C99 requires
valid prototypes (not just declarations like "void foo();").
And constructs like:

foo (bar) char *bar;
{
   return printf("%s\n", bar);
}

are no longer valid (default int & parameter declarations/promotions).

--
begin 664 .signature
M<F5L;&E-("Y'(&-I<D4@/G1E;BYS<&I`,FUG93P)"`@("`@("`@("`@("`@(
M"`@("`@("`@("`@("`@("`A%<FEC($<N($UI;&QE<B`\96=M,D!J<',N;F5T
"/@H`
`
end

On Thu, Oct 03, 2002 at 07:28:11PM -0700, Eric G. Miller wrote:

On Thu, Oct 03, 2002 at 10:14:06AM -0700, roger wrote:

> You can use the -ansi flag to force gcc to support full ANSI
> features and to disable non-ANSI features. If you then use
> -pedantic the compiler will reject any code that is not ANSI
> standard. The error.log will contain a list of uncompiled
> code.

Generally speaking, K&R C is perfectly valid ANSI C89/90.
So, -ansi -pendantic might not change much.

Probably K&R C refers to the first revision of the book.
AFAIK the first revision was not ANSI C.

C99 requires valid prototypes (not just declarations like "void
foo();").

We don't want C99 anyway. :slight_smile: