Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22058

Finding pointer arguments with GnuCParser?

$
0
0

I'm trying to parse this fragment of C code:

void foo(const int *bar, int * const baz);

using GnuCParser, part of pycparserext.

Based on this answer I expected to see some PtrDecls, but here's what I get from ast.show() on the resulting parse tree:

FileAST:
  Decl: foo, [], [], []
    FuncDecl:
      ParamList:
        Decl: bar, ['const'], [], []
          TypeDeclExt: bar, ['const']
            IdentifierType: ['int']
        Decl: baz, [], [], []
          TypeDeclExt: baz, []
            IdentifierType: ['int']
      TypeDecl: foo, []
        IdentifierType: ['void']

Notice how baz, a "const pointer to int", doesn't have a trace of const (or "pointeryness") in the data printed by ast.show(). Is this difference because of GnuCParser?

How do I figure out the type of baz from the AST? My actual C code needs the GNU parser. I'm using pycparserext version 2016.1.

UPDATE: I've created a pycparserext issue on GitHub.


Viewing all articles
Browse latest Browse all 22058

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>