Closed hvaldecantos closed 8 years ago
similar case in GZIP project, the following macros were detected as global variables:
MAX_DIST,./lib/match.c,107,2725db10000bae65e311a9329973b11053b86f1a,2
MAX_MATCH2,./lib/match.c,145,2725db10000bae65e311a9329973b11053b86f1a,1
_good_match,./lib/match.c,115,2725db10000bae65e311a9329973b11053b86f1a,1
_max_chain_length,./lib/match.c,104,2725db10000bae65e311a9329973b11053b86f1a,1
_nice_match,./lib/match.c,161,2725db10000bae65e311a9329973b11053b86f1a,1
_prev_length,./lib/match.c,112,2725db10000bae65e311a9329973b11053b86f1a,1
_strstart,./lib/match.c,105,2725db10000bae65e311a9329973b11053b86f1a,1
_window,./lib/match.c,154,2725db10000bae65e311a9329973b11053b86f1a,1
These are macros created to be used in assembly language sections within a .c
file. As we are analysing C language we should get rid of them. The before mentioned workaround should work for these cases too.
Enforcing to C language in ctags command gets the same results.
$ ctags -x --c-kinds=v --file-scope=no --language-force=c
It works at file level.
In CPIO project, ATTRIB_PACKED was detected as global variable.
The macro is defined as:
When preprocessing
cpiohdr.h
ATTRIB_PACKED is replace for__attribute__((packed))
to set alignment of memory space. As in:What I understand is that this macro instructs the newly defined
struct old_cpio_header
(and other structs) to align memory space when declaring variables of this type. Therefore,ATTRIB_PACKED
shouldn't be considered a global variable.__attribute__((packed))
Valid application: As a variable attribute, it applies to simple variables, or individual members of an aggregate, namely a structure, union or class.1 As a type attribute, it applies to all members of all aggregates declared of that type. Effect: Sets the maximum alignment of the selected variable, or variables, to which it applies, to the smallest possible alignment value, namely one byte for a variable and one bit for a bit field.http://scv.bu.edu/computation/bluegene/IBMdocs/compiler/xlc-8.0/html/proguide/ref/modifiers.htm#modifiers http://stackoverflow.com/questions/841433/gcc-attribute-alignedx-explanation
Workaround One way of ignoring macro definition:
As this is not practical, we have to detect first all susceptible macros of being detected as global variables and create a file with the tokens to be ignored.