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

Refactor the C++ version of unique_id so it can be included in more than one cpp file #7

Closed
corot opened this issue Sep 22, 2014 · 13 comments
Assignees

Comments

@corot
Copy link

corot commented Sep 22, 2014

Just put "inline" on each function should do the trick, or (more tedious) separate the implementation in a cpp. Otherwise, it's a pain to use is in multiple source files.

Or am I missing the right use of it? In that case, please feel free to close this, and... ideally give me a solution 🙏

@jack-oquin
Copy link
Member

Thanks for the report.

This looks like a bug, and none of my test cases catch it. I'll try to construct a test for it, then fix it when I can demonstrate the error.

Your "inline" suggestion makes sense to me. None of those functions seem large enough to be worth creating a separate .cpp file and a shared library to contain it.

@jack-oquin jack-oquin self-assigned this Sep 29, 2014
@jack-oquin
Copy link
Member

Reproducing this bug is easy: adding another .cpp file to the test_unique_id executable with an include of unique_id.h produces the expected linker failure.

@corot
Copy link
Author

corot commented Sep 30, 2014

Well, I tried the inline approach and I got some difficulties for compiling (I don't remember what errors exactly, but was related to the underlying boost implementation), so I separated implementation and headers:
https://github.com/corot/world_canvas_libs/blob/master/world_canvas_client_cpp/include/world_canvas_client_cpp/unique_id.hpp

@jack-oquin
Copy link
Member

Yes. I think you're right. The problem is that impl/unique_id.h instantiates several boost function and data objects, which really requires a separate compilation unit, like the solution you came up with. That approach does separate the interface from the implementation more cleanly.

That will work for Indigo. But, I am reluctant to release an ABI-breaking change like that to Hydro at this point.

I suppose we could consider releasing it to Hydro anyway, if necessary. Since no one had previously reported this bug, they must have only included unique_id.h in a single C++ compilation, so maybe they will not notice the binary interface change. But, it might break build compatibility for packages that need to add or modify a target_link_libraries() statement.

@jack-oquin
Copy link
Member

According the ROS wiki page "used by" links for Hydro and Indigo, the only indexed packages using this one are ROCON components and also the geodesy package. Most of those references are in Python, not C++. So, we can probably release this fix to both distributions, if desired.

@jack-oquin
Copy link
Member

I finally got back to working on this problem.

Declaring everything static solves the problem for my tests. I also made the API functions inline as you suggested.

Please run your test with this fix and let me know if it solves the original problem. If so, I will release it to both Hydro and Indigo.

@jack-oquin
Copy link
Member

@corot: does the latest master using static inline fix your problem?

@jack-oquin
Copy link
Member

Even without further test verification, I am releasing this to Indigo and Jade.

Do you need a Hydro release, too?

@jack-oquin
Copy link
Member

Fixed for Indigo and Jade in release 1.0.5.

corot added a commit to corot/world_canvas_libs that referenced this issue Apr 30, 2015
corot added a commit to corot/world_canvas_tools that referenced this issue Apr 30, 2015
@corot
Copy link
Author

corot commented Apr 30, 2015

Hi @jack-oquin, sorry for the delay. Works fine now, so I removed the wrapper. Thanks!

@jack-oquin
Copy link
Member

Glad it fixes your problem. I released it to Indigo and Jade, but not Hydro.

Do you need a Hydro release for this?

@corot
Copy link
Author

corot commented May 1, 2015

We use indigo, so no problem for us. I think you don't need to bother to release on hydro

@jack-oquin
Copy link
Member

Sounds good. Since Hydro is near end-of-life I see no need to release it there.

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