#249 'extern "C" keeps global definitions from being recognized

Tang Yi

issue desc: Can not find definition of member of a enum when using #external "C".
cscope version: 15.7a
more detail: see below issue reproduce demo, member named as "DAAA" can no be found with a "extern "C"" keyword.
Workaround: After comment all code line with "external = YES;" in fscanner.c and fscanner.l and scanner.c and scanner.l, it works.

yibox cscope_enum_test # cat t.h
typedef enum
AAAA =0,

extern "C" {
typedef enum
DAAA =0,

yibox cscope_enum_test # cscope --version
cscope: version 15.7a
yibox cscope_enum_test # cscope -b t.h
yibox cscope_enum_test # cscope -d -L1DAAA
yibox cscope_enum_test # cscope -d -L1AAAA
yibox cscope_enum_test #


  • Hans-Bernhard Broeker

    I keep having to point that out: cscope is not designed to be c++scope, so problems like this are to be expected to some extent.

    The key to this problem is that serach -1 doesn't just find definitions. It finds _global_ definitions. The problem with that is the extra set of curly braces from the extern "C", which doesn't exist in C, and which to cscope look like this typedef is just a block-scoped definition, instead of a global one.

    It would require some considerable rework of the lexers to allow cscope to ignore the entire extern "C" { } construct. It interferes with brace nesting counts.

  • Tang Yi

    Tang Yi - 2009-11-22

    Understand your clarify. cscope is major designed for C code, support for C++ is not as good as for C.
    btw, i find a link/page (http://www.fsl.cs.sunysb.edu/~rick/cscope.html) which help me to resolve this problem without modify cscope's code, just using ctags and cscope together to do a more smart analysis for C/CPP symbol definition for c and CPP mixed code.
    If cscope can full support c++ in the future, i think it is a best solution. :)
    anyway, thanks a lots.

  • Hans-Bernhard Broeker

    • summary: Can not find definition of member of a enum. --> 'extern "C" keeps global definitions from being recognized
    • status: open --> pending-invalid

Log in to post a comment.