-
Notifications
You must be signed in to change notification settings - Fork 317
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
C++ API updated for new C-API #1112
Conversation
since: the cpp bindings are off by default - https://github.com/analogdevicesinc/libiio/blob/61fdbe78c298570bbc0c9e9ec3ce1a7c1fa3742e/CMakeLists.txt#L651C1-L651C48 now things are working - we should turn them on for CI where we want to... likely here for linux: Line 75 in 61fdbe7
and here for mac: https://github.com/analogdevicesinc/libiio/blob/61fdbe78c298570bbc0c9e9ec3ce1a7c1fa3742e/azure-pipelines.yml#L337C4-L337C4 and here for windows: Line 14 in 61fdbe7
and here for linux on ARM: https://github.com/analogdevicesinc/libiio/blob/61fdbe78c298570bbc0c9e9ec3ce1a7c1fa3742e/CI/azure/ci-ubuntu.sh that way everything will get at least build tested on CI... |
4bdee76
to
43d3e7c
Compare
Static code analysis passes. The Linux builds fail due to a missing C++ compiler. The windows build fails because boost is not installed. Maybe someone who has experience with this CI-stuff can take a look at it? |
Centos fails since If BOOST is a requirement - we should check for it in the CMAKE, and tell people to install it... something like:
If you need specific modules - add them rather than I think Travis can add BOOST to the docker image in Jan. |
So, boost is not a hard requirement for windows... The code:
However - Visual Studio only fills out the With maybe some more CMAKE to see if it needs to check for boost... |
06908d2
to
dd3be2f
Compare
Yes. Actually it is not required with VS 2017 and later. Fixed that and a few minor problems (warnings that showed up with MS build). |
So, then we are left with: LinuxBuilds fedora34:
debug : Install a C++ compiler in fedora34 image. I think @tfcollins needs to do this. LinuxBuilds centos_7:
which was released June 23, 2015, before the cpp 2017 spec was written. Either figure out how to make it work without, and have BOOST installed, or (my suggestion) just turn it off in the |
@sternmull thanks a lot! I'll have a proper look next week. |
Container updated sdgtt/Dockerfiles@5ade294 Will be ready in 30 minutes |
@tfcollins - thanks - can someone with admin rights re-start the fedora build? or @sternmull can you squash things and push so things re-build? |
All checks pass now. |
Stream(iio_stream * s) : p(s){} | ||
operator iio_stream * () const {return p;} | ||
|
||
Block next_block() {return const_cast<iio_block *>(impl::check(iio_stream_get_next_block(p), "iio_stream_get_next_block")); } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't the iio_block be deleted when it gets out of scope?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the Block-class does not manage the lifetime of the referenced object. It is just a shallow wrapper for calling its functions.
See the comment at the top of the header. This should explain how the C++ classes manage resources.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, thanks.
bindings/cpp/iiopp.h
Outdated
void enable() {impl::check(iio_buffer_enable(p), "iio_buffer_enable");} | ||
void disable() {impl::check(iio_buffer_disable(p), "iio_buffer_disable");} | ||
ChannelsMask channels_mask() {return iio_buffer_get_channels_mask(p);} | ||
BlockPtr crate_block(size_t size) { return BlockPtr{impl::check(iio_buffer_create_block(p, size), "iio_buffer_create_block")}; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
crate_block
-> create_block
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops. Committed a fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you merge it into the first commit maybe?
I'll also need you to sign all the commits (currently only the first one is signed).
Signed-off-by: Tilman Blumhagen <tilman.blumhagen@googlemail.com>
MSVC 2017 has std::optional even if it does not yet implement C++17. See https://learn.microsoft.com/en-us/cpp/overview/visual-cpp-language-conformance?view=msvc-170https://learn.microsoft.com/en-us/cpp/overview/visual-cpp-language-conformance Signed-off-by: Tilman Blumhagen <tilman.blumhagen@googlemail.com>
Its C++ compiler is too old (or we would need boost). Signed-off-by: Tilman Blumhagen <tilman.blumhagen@googlemail.com>
Done |
Merged, thanks a lot! |
This updates iiopp.h for the latest changes of the C-API. It should fix issue #1046.
But be warned: I currently have no system with iio devices available for testing. So this is completely untested code!
The small example compiles and in general the code should be easy to read and review. I hope i didn't introduce any bugs. Please keep that in mind and review and test it carefully.