Project

General

Profile

Bug #1674

"struct swap" creates ambiguity with C++ swap functions

Added by John Baxter almost 5 years ago. Updated over 4 years ago.

Status:
Closed
Priority:
Low
Assignee:
-
Category:
mdrun
Target version:
Affected version - extra info:
release-5-0
Affected version:
Difficulty:
uncategorized
Close

Description

I discovered compilation-error causing ambiguity in C++ code between "struct swap" (defined in "src/gromacs/swap/swapcoords.cpp") and functions called "swap" (in my case introduced when including <boost/array.hpp>, but overloading swap is common in many other libraries as well).

Here is how the struct is currently defined and typedef'd:

typedef struct swap {...} t_swap;

In all but one other place (in "src/gromacs/legacyheaders/types/inputrec.h"), "t_swap" is already used instead of "struct swap". To resolve the ambiguity, the two instances of "swap" can be replaced with "t_swap". In testing I was able to compile without issue after these changes.

The benefit of applying this fix is that C++ libraries which overload "swap" will be able to be used together with gromacs. The potential risk is that 3rd party extensions which currently use "struct swap" instead of "t_swap" would need to be updated; my intuition is that this risk is small compared to the benefit.

Below are the proposed changes:

file: .../src/gromacs/swap/swapcoords.cpp
line: 152
old: typedef struct swap
new: typedef struct t_swap

file: .../src/gromacs/legacyheaders/types/inputrec.h
line: 286
old: typedef struct swap *gmx_swapcoords_t;
new: typedef struct t_swap *gmx_swapcoords_t;

Associated revisions

Revision 63f1fc3a (diff)
Added by John Baxter almost 5 years ago

Changed "struct swap" to "struct t_swap"

Fixes #1674

Change-Id: Ia3917dd2ee9d30d2d280bd00fba8953b2eb5b432

History

#1 Updated by Roland Schulz almost 5 years ago

Sounds like a good idea. Can you upload a change to gerrit.gromacs.org?

#3 Updated by John Baxter almost 5 years ago

I've updated the copyright dates to 2015 for the related files.

https://gerrit.gromacs.org/#/c/4403

#4 Updated by Mark Abraham almost 5 years ago

  • Category set to mdrun
  • Target version set to 5.1
  • Affected version - extra info set to release-5-0

Indeed looks good, thanks.

#5 Updated by Gerrit Code Review Bot almost 5 years ago

Gerrit received a related patchset '6' for Issue #1674.
Uploader: John Baxter ()
Change-Id: Ia3917dd2ee9d30d2d280bd00fba8953b2eb5b432
Gerrit URL: https://gerrit.gromacs.org/4402

#6 Updated by Mark Abraham over 4 years ago

  • Status changed from New to Resolved

#7 Updated by Mark Abraham over 4 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF