8000 C linkage APIs cannot return a reference · Issue #148 · L-Acoustics/avdecc · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

C linkage APIs cannot return a reference #148

New issue

Have a question about this project? Sign up for a free GitHub a 8000 ccount 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

Closed
lhoward opened this issue Feb 10, 2024 · 6 comments
Closed

C linkage APIs cannot return a reference #148

lhoward opened this issue Feb 10, 2024 · 6 comments
Milestone

Comments

@lhoward
Copy link
Contributor
lhoward commented Feb 10, 2024

Commit c5a5d54 (I think) is causing some problems building on my Linux arm64 build host, specifically:

/home/lukeh/CVSRoot/padl/AVDECCSwift/Sources/CxxAVDECC/avdecc/src/bindings/c/protocolInterface_c.hpp:37:104: error: 'getProtocolInterface' has C-linkage specified, but returns user-defined type 'la::avdecc::protocol::ProtocolInterface &' which is incompatible with C [-Werror,-Wreturn-type-c-linkage]
LA_AVDECC_BINDINGS_C_API la::avdecc::protocol::ProtocolInterface& LA_AVDECC_BINDINGS_C_CALL_CONVENTION getProtocolInterface(LA_AVDECC_PROTOCOL_INTERFACE_HANDLE const handle);
...

I would have hoped that passing -a "-DCMAKE_COMPILE_WARNING_AS_ERROR" -a "--compile-no-warning-as-error" to gen_cmake.sh would have helped, but alas no.

@lhoward
Copy link
Contributor Author
lhoward commented Feb 10, 2024

(Moreover presumably functions returning ref params shouldn't have C linkage...)

@christophe-calmejane christophe-calmejane added this to the Release 4.0 milestone Feb 20, 2024
@christophe-calmejane
Copy link
Collaborator

Hi Luke, thanks for the info. You are right, while fixing bindings that were previously "hidden", some of same were actually invalid for the C language.
I'll fix this as soon as I can find a bit of time.
(I just noticed that my CI don't build the C bindings anymore, it looks like there are a lot more errors now).

@christophe-calmejane
Copy link
Collaborator

I wasn't able to reproduce this specific compilation errors using my linux, but anyhow these methods shouldn't have the external linkage flags, they are private methods. I'll fix it shortly, and I hope you'll be able to compile correctly.

In the future, I hope I'll be able to change the C (manual) bindings to swig bindings, like it's done for C# (python in coming).

@lhoward
Copy link
Contributor Author
lhoward commented Feb 22, 2024

I don't doubt this is the correct fix but it does actually break my clang block wrappers which call getAggregateEntity(). I'll maintain a private fork with c5a5d54 and ab08c65 reverted for now, and try come up with a better fix down the track.

(The correct fix will be to use the C++ API directly, but I'm waiting for Swift's C++ interop to catch up. Perhaps by the time I need to use this code in anger it will have.)

@christophe-calmejane
Copy link
Collaborator

That's very interesting as both commit (together) merely change the defines that should never have been there, so it shouldn't be the cause of the recent compilation issues you have.
Nevertheless, the file should not be included in a C project since it's really supposed to be an internal file used by the c++ code (but I do understand that you need to work around limitations of SwiftC++). If it does work for you with the 2 commits reverted, it shouldn't have any impact at all on the rest of the code so it's great if it's a workaround for you at the moment ;)

@lhoward
Copy link
Contributor Author
lhoward commented Feb 22, 2024

Yeah, it’s more about symbol visibility, with the latest commit they’re no longer exported from the shared library.

lhoward added a commit to PADL/avdecc that referenced this issue Mar 15, 2024
lhoward added a commit to PADL/avdecc that referenced this issue Apr 1, 2024
lhoward added a commit to PADL/avdecc that referenced this issue Feb 21, 2025
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

2 participants
0