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

Redefine error when using C++ #1222

Closed
EricB-ADI opened this issue Oct 10, 2024 · 3 comments
Closed

Redefine error when using C++ #1222

EricB-ADI opened this issue Oct 10, 2024 · 3 comments

Comments

@EricB-ADI
Copy link
Contributor

EricB-ADI commented Oct 10, 2024

I am working on an internal project with c++.

I am getting a redefinition error

In file included from /home/eric-busch/Workspace/msdk/Libraries/CMSIS/Device/Maxim/MAX32655/Include/max32655.h:257,
                 from /home/eric-busch/Workspace/msdk/Libraries/PeriphDrivers/Include/MAX32655/mxc_device.h:24,
                 from ../../../../../Libraries/RF-PHY/MAX32655/include/dbb_registers.h:51,
                 from inc/tester.hpp:14,
                 from src/tester.cpp:7:

core_cm4.h:222: warning: "__I" redefined

where it is previously defined

gpio_regs.h:53: note: this is the location of the previous definition

core_cm4.h

#ifdef __cplusplus
  #define   __I     volatile             /*!< Defines 'read only' permissions */
#else
  #define   __I     volatile const       /*!< Defines 'read only' permissions */
#endif
#define     __O     volatile             /*!< Defines 'write only' permissions */
#define     __IO    volatile             /*!< Defines 'read / write' permissions */

/* following defines should be used for structure members */
#define     __IM     volatile const      /*! Defines 'read only' structure member permissions */
#define     __OM     volatile            /*! Defines 'write only' structure member permissions */
#define     __IOM    volatile            /*! Defines 'read / write' structure member permissions */

What doesn't make sense to me is volatile const basically says its hardware that can only be read by the software, which makes sense for the input. Why c++ matters is beyond me. Seems like a bug, but is clearly intentional.

gpio_regs.h

#ifndef __IO
#define __IO volatile
#endif
#ifndef __I
#define __I  volatile const
#endif
#ifndef __O
#define __O  volatile
#endif
#ifndef __R
#define __R  volatile const
#endif

There must be some place core_cm4.h is getting included after gpio_regs.h
Only reason it is not an issue before is the defs are the same when using c.

Option 1: basically copy the core_cm4.h files. or

It looks like this

#ifndef __IO
#define __IO volatile
#endif
#ifndef __I
#ifdef __cplusplus
  #define   __I     volatile             /*!< Defines 'read only' permissions */
#else
  #define   __I     volatile const       /*!< Defines 'read only' permissions */
#endif
#endif
#ifndef __O
#define __O volatile
#endif
#ifndef __R
#define __R volatile const
#endif

Only gpio_regs.h and dbb_ctrl_regs.h have this issue.

Option 2: #include "core_cm4.h" and only define __R

If you have a better idea let me know.

@sihyung-maxim @Jake-Carter

@Jake-Carter
Copy link
Contributor

@EricB-ADI can you attach that tester.hpp file? Having a hard time replicating

@EricB-ADI
Copy link
Contributor Author

@ttmut Linked this https://developer.arm.com/documentation/ka002980/latest

Yes, it should be updated as const will get optimized volatile or not.
The register script is in an internal repo, so I can play with it there.

@EricB-ADI
Copy link
Contributor Author

Addressed in #1228

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