Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

std::function causes "Unable to find out actual class definition: 'type'." #137

Open
AntonShalgachev opened this issue Dec 23, 2020 · 0 comments

Comments

@AntonShalgachev
Copy link

Hey,
pygccxml is having troubles parsing the following C++ code:

#include <functional>
int main()
{
    std::function<void()> func = [](){};
}

If parsed from file, this code results in the following error:

Unable to find out actual class definition: 'type'.
Class definition has been changed from one compilation to an other.
Why did it happen to me? Here is a short list of reasons: 
    1. There are different preprocessor definitions applied on same file during compilation
    2. Bug in pygccxml.

When parsing the same code from string I don't get any errors. Adding compilation_mode=parser.COMPILATION_MODE.ALL_AT_ONCE to the parser.parse also helps

Platform: Windows
XML generator: castxml
Python: 3.7.0

Full python code:

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

# specific to my setup
compiler_path = r'C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\Hostx86\x86\cl.exe'
include_paths = [
    r'C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/include',
    r'C:/Program Files (x86)/Windows Kits/10/Include/10.0.19041.0/ucrt',
]

filename = r'example.cpp'

code = """
#include <functional>
int main()
{
    std::function<void()> func = [](){};
}
"""

file_content = ''
with open(filename, 'w') as f:
    f.write(code)

generator_path, generator_name = utils.find_xml_generator('castxml')

xml_generator_config = parser.xml_generator_configuration_t(
    xml_generator_path=generator_path,
    xml_generator=generator_name,
    compiler_path=compiler_path,
    include_paths=include_paths)

decls = parser.parse_string(code, xml_generator_config)  # succeeds
decls = parser.parse([filename], xml_generator_config)  # fails

This issue might be relevant: #105

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant