Skip to content

Fix ParseHeader() can only report the last file's error in non unityBuild mode#1945

Closed
zhaojunmeng wants to merge 0 commit intomono:mainfrom
zhaojunmeng:main
Closed

Fix ParseHeader() can only report the last file's error in non unityBuild mode#1945
zhaojunmeng wants to merge 0 commit intomono:mainfrom
zhaojunmeng:main

Conversation

@zhaojunmeng
Copy link
Contributor

        if (i < Headers.size() - 1)
            // Before modified, the ParseResult is just deleted without checking whether it has any error.
            delete parser.Parse({ Headers[i] });
        else
            res = parser.Parse({ Headers[i] });

Change to: if any file has non success ParseResult, just stop parsing and return the result.

@zhaojunmeng
Copy link
Contributor Author

Error parsing 'Builtins.h, Classes.h, Classes2.h, Delegates.h, Enums.h, Overloads.h'
/home/runner/work/CppSharp/CppSharp/tests/Builtins.h(3,10): fatal: 'cstddef' file not found
CppSharp has encountered an error while parsing code.

It seems that the error that already existed in the previous CI pipeline has been exposed by this merge quest.😭

@tritao
Copy link
Collaborator

tritao commented Dec 2, 2025

@zhaojunmeng Is this fix still necessary?

@zhaojunmeng
Copy link
Contributor Author

@zhaojunmeng Is this fix still necessary?

I believe this is necessary. When I first used CppSharp, I couldn’t generate the wrapper files for my project because some of the header files I parsed had compilation errors—but the ParseHeader() function only reported the parse result of the last header file (which was successful). This took me one day to identify the actual issue.

But I’m having trouble passing the CI action on the Linux platform.

Run tests/emscripten/test.sh --dotnet-config $BUILD_CONFIGURATION
Generating bindings with .NET configuration Debug
Generating Emscripten bindings for Emscripten WASM32...
Parsing libraries...
Parsing code...
Error parsing 'Builtins.h, Classes.h, Classes2.h, Delegates.h, Enums.h, Overloads.h'
/home/runner/work/CppSharp/CppSharp/tests/Builtins.h(3,10): fatal: 'cstddef' file not found
CppSharp has encountered an error while parsing code.

I thought the include path isn’t set up correctly on Linux when running Emscripten’s tests for tests/Builtins.h to find cstddef.h and cstdint.h.

@tritao
Copy link
Collaborator

tritao commented Dec 2, 2025

Ok, I can try to help and see what's going on. Can you please re-open or send another PR with this fix?

@zhaojunmeng
Copy link
Contributor Author

Ok, I can try to help and see what's going on. Can you please re-open or send another PR with this fix?

Thanks, that would be nice! I'll send a new PR for this.

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

Successfully merging this pull request may close these issues.

2 participants