Skip to content

Allow header files to be parsed by C++ parsers #1660

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

Merged
merged 2 commits into from
Aug 22, 2018
Merged

Allow header files to be parsed by C++ parsers #1660

merged 2 commits into from
Aug 22, 2018

Conversation

alblue
Copy link
Contributor

@alblue alblue commented Aug 14, 2018

By replacing namspace with name_space and changing the restrict into __restrict__ in C++ mode, the headers can now be parsed by clang++ as well as clang.

@alblue
Copy link
Contributor Author

alblue commented Aug 14, 2018

@swift-ci please test

#define CF_RESTRICT restrict
#endif
#endif

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a public header so we can't just add the macro here. Perhaps ForSwiftFoundationOnly.h?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The restrict is used in CFPlatform.c and CFStorage.c, so could move it into CFInternal.h instead?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking CFInternal as well, but then it's used in ForSwiftFoundationOnly.h. I'd prefer the internal header if possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it looks like if we put it in CFInternal.h then it can't be used for the ForSwiftFoundationOnly.h. We could have the macro in CFInternal for ease of maintenance and then have a special-case for the ForSwiftFoundationOnly that duplicates it, but it's not elegant.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So @parkera I have moved the definitions to be internal only, but can't use it in the ForSwiftFoundation file. I'm not sure which approach you'd like me to take here in terms of conditionally defining the value of restrict -- I've duplicated the line here, but it's introducing duplicate code which I don't like. Any other preferences/suggestions?

@alblue
Copy link
Contributor Author

alblue commented Aug 15, 2018

@swift-ci please test

1 similar comment
@alblue
Copy link
Contributor Author

alblue commented Aug 15, 2018

@swift-ci please test

@alblue
Copy link
Contributor Author

alblue commented Aug 21, 2018

@parkera any thoughts as to the new approach suggested here?

Copy link
Contributor

@parkera parkera left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with this approach. If we have need for this macro elsewhere we can refactor it again a bit more.

@alblue
Copy link
Contributor Author

alblue commented Aug 22, 2018

@swift-ci please test and merge

@swift-ci swift-ci merged commit b610bd5 into swiftlang:master Aug 22, 2018
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.

3 participants