{"id":21089,"library":"cxxheaderparser","title":"cxxheaderparser","description":"A modern, Python-based parser for C++ header files. It can parse C++ headers into an AST and optionally generate a JSON representation. Version 1.7.0 supports Python >=3.6. Releases are occasional, with active maintenance.","status":"active","version":"1.7.0","language":"python","source_language":"en","source_url":"https://github.com/abseil/abseil-cpp","tags":["C++","header parser","AST","clang"],"install":[{"cmd":"pip install cxxheaderparser","lang":"bash","label":"Install from PyPI"}],"dependencies":[],"imports":[{"note":"Main entry point for parsing a file","symbol":"parse_file","correct":"from cxxheaderparser import parse_file"},{"note":"Parse C++ header string","symbol":"parse_str","correct":"from cxxheaderparser import parse_str"},{"note":"Options for parser behavior","symbol":"ParserOptions","correct":"from cxxheaderparser.options import ParserOptions"},{"note":"Result of parsing","symbol":"ParsingResult","correct":"from cxxheaderparser.types import ParsingResult"}],"quickstart":{"code":"from cxxheaderparser import parse_str\n\ncode = '''\nint add(int a, int b);\n'''\nresult = parse_str(code)\nprint(result.namespace.name_qual)\nprint(result.functions[0].name)  # 'add'","lang":"python","description":"Parse a simple header string and access parsed functions."},"warnings":[{"fix":"Run your code through a preprocessor (e.g., cpp) before parsing, or avoid macro-heavy headers.","message":"The parser expects valid C++ syntax. Preprocessor macros (#define, #ifdef) are not resolved and may cause parse errors or unexpected AST. Use a preprocessor or pass already-preprocessed code.","severity":"gotcha","affected_versions":"all"},{"fix":"Stick to C++17 or earlier for reliable parsing. Consider libclang-based alternatives if full standard support is needed.","message":"The library does not fully support C++20 concepts, modules, or some newer features. Parsing may fail on modern templates or requires.","severity":"gotcha","affected_versions":"all"},{"fix":"Use `from cxxheaderparser import parse_file` instead of `from cxxheaderparser import parse`.","message":"Between versions 0.x and 1.x, the API changed significantly. The old `cxxheaderparser.parse` module was restructured into `cxxheaderparser` package with new import paths.","severity":"breaking","affected_versions":"0.x -> 1.0.0+"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Run `pip install cxxheaderparser`","cause":"Package not installed or wrong environment.","error":"ModuleNotFoundError: No module named 'cxxheaderparser'"},{"fix":"Simplify the header, preprocess with cpp, or check supported C++ version.","cause":"The input C++ code has syntax that the parser cannot handle (e.g., macro, C++20 feature).","error":"cxxheaderparser.errors.ParseError: ..."},{"fix":"Replace `from cxxheaderparser import parse` with `from cxxheaderparser import parse_file` or `parse_str`.","cause":"Using old import path from version 0.x.","error":"AttributeError: module 'cxxheaderparser' has no attribute 'parse'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}