pycparserext icon indicating copy to clipboard operation
pycparserext copied to clipboard

stddef.h include issue

Open KoenVda88 opened this issue 2 years ago • 2 comments

Hi,

I like this software though I found an issue when parsing a preprocessed file with stddef.h included.

The software seems to have issues with:

typedef struct {
  long long __max_align_ll __attribute__((__aligned__(__alignof__(long long))));
  long double __max_align_ld __attribute__((__aligned__(__alignof__(long double))));
} max_align_t;

My code:

class FunctionList(pycparser.c_ast.NodeVisitor):
	def __init__( self, source):
		self.funcs = set()
		parser = ext_c_parser.GnuCParser()
		self.visit(parser.parse(source))

	def visit_FuncDef(self, node):
		self.funcs.add(node.decl.name)

With source as the preprocessed file with args = ['gcc','-E','-P' ]

Any solutions to this issue?

Thanks!

KoenVda88 avatar Mar 03 '22 21:03 KoenVda88

I'm unlikely to have time to fix this myself, but I'd be happy to take a PR.

inducer avatar Mar 03 '22 21:03 inducer

I looked at the code but it seems not like an easy fix. I did find a workaround though I run gcc with -D__alignof__(x)=sizeof(x) I know this is not a good fix but I don't use max_align_t so I don't mind it.

KoenVda88 avatar Mar 05 '22 15:03 KoenVda88