bug-cflow
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-cflow] cflow: macro detection


From: Sergey Poznyakoff
Subject: Re: [bug-cflow] cflow: macro detection
Date: Sat, 09 Jun 2012 08:41:21 +0300

Ramiro Magno <address@hidden> ha escrit:

> => detecting the macro min() but not the macro max() because it is
> shadowed by the local var max I believe.

Yes, exactly.

> Is this a bug or a feature? Can this be circumvented?

It is neither. Actually, it is a syntax error in the input, If max() had
been a function instead of macro, you'd get a syntax error there, both
by cc and cflow.  Since it is a macro, the compiler does not see it at
all, because it gets expanded in its input stream. Cflow, however, gets
the input as it is and sees what looks to it like a variable used as a
function. It treats it as a syntax error, but tries to continue anyway:
it is not a compiler after all, so it is more tolerant to its input.

To get reliable results, I'd suggest always using preprocessor, so that
cflow see exactly the same source as the compiler:

$ cflow --cpp -i x 1.c
main() <int main () at 1.c:7>:
    fn() <void fn (int a, int b) at 1.c:13>

You'll have to use the preprocessing mode for any non-trivial source
anyway.  See Cflow Manual, chapter 7 for a detailed discussion:

  http://www.gnu.org/software/cflow/manual/html_node/Preprocessing.html

Regards,
Sergey




reply via email to

[Prev in Thread] Current Thread [Next in Thread]