CastXML / pygccxml

pygccxml is a specialized XML reader that reads the output from CastXML or GCCXML. It provides a simple framework to navigate C++ declarations, using Python classes.
Boost Software License 1.0
129 stars 44 forks source link

unknown type name 'EventId' error #103

Closed sumiteshpurohit closed 3 years ago

sumiteshpurohit commented 5 years ago

When parsing several files from ns3 (e.g. src/mobility/model/random-waypoint-mobility-model.h), we are getting this error

error: unknown type name 'EventId' EventId m_event; //!< event ID of next scheduled event

Can you please help here?

iMichka commented 5 years ago

Hi. Could you provide that file, or at least a reduced example which is failing?

sumiteshpurohit commented 5 years ago

Hi. Thanks for looking into this.

Below is the code i am running:

from pygccxml import utils
from pygccxml import declarations
from pygccxml import parser

# Find the location of the xml generator (castxml or gccxml)
generator_path, generator_name = utils.find_xml_generator()

# Configure the xml generator
xml_generator_config = parser.xml_generator_configuration_t(
    xml_generator_path=generator_path,
    xml_generator=generator_name,
    cflags="-std=c++11", include_paths = ["build"])

# The c++ file we want to parse
filename = "src/mobility/model/random-waypoint-mobility-model.h"

# Parse the c++ file -- this is where the code is failing
decls = parser.parse([filename], xml_generator_config)

# Get access to the global namespace
global_namespace = declarations.get_global_namespace(decls)

# Get access to the 'ns' namespace
ns = global_namespace.namespace("ns")

Ans below is the snapshot of error which I am getting. image

The code is failing at this statement: decls = parser.parse([filename], xml_generator_config)

Please let me know if you need any other info.

dermont123 commented 5 years ago

Try adding the header containing EventId first, e.g: ns3.zip

sumiteshpurohit commented 5 years ago

Try adding the header containing EventId first, e.g: ns3.zip

This works, thank you very much.

iMichka commented 3 years ago

Looks like this has been solved as the header needed to be included first.