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

Motor Control library used by ETH boards is now compiled in C++ #397

Merged
merged 3 commits into from
Jul 19, 2023
Merged

Motor Control library used by ETH boards is now compiled in C++ #397

merged 3 commits into from
Jul 19, 2023

Conversation

marcoaccame
Copy link
Contributor

The files of the motor control library used by the ETH boards are now compiled in C++ mode.

This library was originally developed to run in a C environment on the ETH boards (ems etc).
Over the years, some of its .c files have been added C++ model generated code and so they have been compiled in C++ mode.

Now, we need some other files to contain C++ code, so I have moved all the files into C++ compilation.
To allow a correct compilation on the ETH boards where the functions w/ prefix MController_* are ued by both C and C++ modules, I have done a minor change to the .h files. In particular:

  • I kept the dual C and C++ linkage only in the file Controller.h which contains the public interface:
    #ifdef __cplusplus
    extern "C" {
    #endif
    
    // code of `Controller.h` in here
    
    #ifdef __cplusplus
    }       // closing brace for extern "C"
    #endif 
  • I added in file Controller.h an opaque struct for the MController which is used only via it pointer. ```
  • I removed the C linkage from the other .h files (such as Joint.h etc) that are used only in its internal implementation;
  • I added in file Controller.h an opaque struct for the MController which is used only via it pointer.

The files that use the library have been kept unchanged. Only the projects of the ems, mc4plus and mc2plus now compile the files AbsEncoder.c etc in C++ mode.

There is no change in code that requires a new version of the binaries or tests.

Copy link
Member

@valegagge valegagge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@ale-git ale-git left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@marcoaccame marcoaccame merged commit d501133 into robotology:devel Jul 19, 2023
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 this pull request may close these issues.

3 participants