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

Compiling error: function definition is marked dllimport #209

Open
felixf4xu opened this issue Jun 3, 2024 · 1 comment · May be fixed by #210
Open

Compiling error: function definition is marked dllimport #209

felixf4xu opened this issue Jun 3, 2024 · 1 comment · May be fixed by #210

Comments

@felixf4xu
Copy link

Hi,

When fastcdr is compiled and installed, I continue to build fastrtps, (compile on Windows and set -DBUILD_SHARED_LIBS=ON),

then I got lots of similar errors:

C:/ros/jazzy/install/include/fastcdr/Cdr.h:2792:21: error: function 'eprosima::fastcdr::Cdr& eprosima::fastcdr::Cdr::deserialize_type(eprosima::fastcdr::EncodingAlgorithmFlag, std::function<bool(eprosima::fastcdr::Cdr&, const eprosima::fastcdr::MemberId&)>)' definition is marked dllimport
 2792 |     Cdr_DllAPI Cdr& deserialize_type(
      |                     ^~~~~~~~~~~~~~~~

the reason is that when compiled as shared lib (dll on windows), Cdr_DllAPI is defined as __declspec( dllexport ) when compiling fastcdr and __declspec( dllimport ) when compiling fastrtps and includes fastcdr as a shared lib.

Then the included header file (for fastftps), is like this

//Cdr.h
    Cdr_DllAPI Cdr& deserialize_type(
            EncodingAlgorithmFlag type_encoding,
            std::function<bool (Cdr&, const MemberId&)> functor)
    {
        return (this->*deserialize_type_)(type_encoding, functor);
    }

the error message says that the function is marked as dllimport but it has a function body (definition) at the same time, which is an error.

The suggested change is to move the function body/definition from .h file to .cpp file.

I'd like to create a PR if the suggestion above is acceptable.

@JesusPoderoso
Copy link
Contributor

Hi @felixf4xu, thanks for using Fast CDR, and for the report.
Sure! Please, go ahead with your contribution!

@felixf4xu felixf4xu linked a pull request Jun 4, 2024 that will close this issue
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

Successfully merging a pull request may close this issue.

2 participants