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

Name anonymous types in api.h #1659

Merged

Conversation

MatthewGentoo
Copy link
Contributor

Anonymous structs cannot be forward declared. This change names anonymous types in api.h so that consumers can forward declare them.

@MatthewGentoo
Copy link
Contributor Author

(I'm unsure why the test test_python_corpus is failing, I can try and rebase on master if it's fixed there)

@MatthewGentoo
Copy link
Contributor Author

ping

Anonymous structs cannot be forward declared.  This change names
anonymous types in api.h so that consumers can forward declare them.
@ahlinc
Copy link
Contributor

ahlinc commented Aug 11, 2023

@MatthewGentoo Could you explain what sense to have forward declarations for structs from the api.h file if the api.h file is protected by #ifndef TREE_SITTER_API_H_ and can be included many times in every place where it's needed?

@dundargoc
Copy link
Member

What problem does this PR solve? I don't get it. I think the C code should work as is.

@MatthewGentoo
Copy link
Contributor Author

Hi, sorry for the delayed response and lack of explanation.

In C and C++, anonymous types can't be forward declared. Forward declaring the types allows for headers in the application to skip including tree_sitter/api.h. While the impact to compile time is quite small (some libraries, especially C++ ones, are a lot worse...) every little helps in larger applications.

@dundargoc
Copy link
Member

dundargoc commented Feb 17, 2024

Eh, I feel like the structs here are so small that I find it hard to believe it'd make much difference. That said, I don't see a problem with including this anyway since it's a non-intrusive change. Thanks for the explanation.

@dundargoc dundargoc merged commit 15e6cd1 into tree-sitter:master Feb 17, 2024
16 checks passed
@MatthewGentoo MatthewGentoo deleted the api/name-anonymous-types branch February 18, 2024 16:48
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.

None yet

3 participants