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

[SR-12263] Unable to access External Fixed size C array in Swift #54691

Open
swift-ci opened this issue Feb 24, 2020 · 2 comments
Open

[SR-12263] Unable to access External Fixed size C array in Swift #54691

swift-ci opened this issue Feb 24, 2020 · 2 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. clang importer Area → compiler: The clang importer compiler The Swift compiler in itself

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-12263
Radar rdar://problem/21374188
Original Reporter somu (JIRA User)
Type Bug

Attachment: Download

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, Importer
Assignee None
Priority Medium

md5: 4ad2f5c7c548964a2a3af5118ef59f45

Issue Description:

Declare an external fixed size C array a1 in a header file

Define the array a1 in the corresponding C file

Import the header file in the bridging header file

In the swift file, the fixed size array a1 is not accessible.

Compilation Error: `Use of unresolved identifier 'a1'`

Project file attached: Please see the attachment for the project file.

Refer: https://forums.swift.org/t/how-to-access-external-fixed-size-c-array-in-swift/34043

@stephentyrone
Copy link
Member

@swift-ci create

@stephentyrone
Copy link
Member

Note in particular that the array has incomplete type in the header:

extern int a1[];

Since this isn't a ConstantArrayType (which would be imported as a tuple), it simply gets dropped on the floor by the importer. I think we should simply import these as Unsafe[Mutable]Pointer<T>, but there's a little bit of subtlety here with various ways arrays are used in C.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added clang importer Area → compiler: The clang importer and removed Importer labels Nov 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. clang importer Area → compiler: The clang importer compiler The Swift compiler in itself
Projects
None yet
Development

No branches or pull requests

3 participants