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

[BUG] Using multiple eRPC clients/server in a C++ project lead to redefinition of struct binary_t #418

Open
PhilippHaefele opened this issue Mar 26, 2024 · 1 comment · May be fixed by #419
Labels

Comments

@PhilippHaefele
Copy link

Describe the bug

We're using multiple eRPC files to generate different server / client connections in one project.
We're using the new namespace feature of 1.12.0 and assign each eRPC file it's own namespace.

As long as we do not have conflicting type names, we do not have any problems.
But as binary_t is implicitly generated for binary, we can't solve this issue by our self.

To Reproduce

Create two .erpc files with both containing a function that uses binary and a different @namespace(".....").
Then include both server (and or clients, so we get the "...common.hpp" file of both included) in on C++ file.

Expected behavior

The code generator, generates code without type conflicts / no compile errors

I think it should be easy by adding the namespace also to the ...._common.hpp file, while generating it via the code generator.

Desktop (please complete the following information)

  • OS: n.a.
  • eRPC Version: 1.12.0
@PhilippHaefele
Copy link
Author

PhilippHaefele commented Mar 27, 2024

Just for other having this issue and can't wait for the fix:
I did try some workarounds (in C++17) and found a ugly one

You need to include (at least) the common header in your desired namespace before including others (this means that you need to be very careful with include order).

namespace YourNamespace
{
#include "...._common.hpp"
}

#include "...._client.hpp"

When fixing this, it should be considered how to handle the constants, as for C usage they need to be global (no namespace). In C++ this extern constants (which are to for some reason weak?) should better be namespaced constexpr, so they can be used in the function prototypes / interface definition e.g. for array sizes

Edit:
weak is there most likely when you compile client and server together to prevent redefinition (and to save a common cpp file just for the constant values).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging a pull request may close this issue.

1 participant