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

Macros BMI_SUCCESS and BMI_FAILURE prevent co-inclusion with C++ bmi-cxx/bmi.hxx #12

Closed
PhilMiller opened this issue Jun 7, 2024 · 1 comment · Fixed by #13
Closed
Assignees
Labels

Comments

@PhilMiller
Copy link
Member

PhilMiller commented Jun 7, 2024

The header bmi.h here contains these macro definitions:

#define BMI_SUCCESS (0)
#define BMI_FAILURE (1)

The C++ header bmi.hxx contains declarations of variables in with those exact same names. Thus, if a source file says

#include <bmi.h>
#include <bmi.hxx>

It will fail to compile, because the compiler will see code that preprocesses to

namespace Bmi {
  const int (0) = 0;
  const int (1) = 1;
}

This is a potential problem for codebases that want to support BMI modules written in either language, and not have to meticulously separate where the two different BMI language binding headers get included, or in which order.

@PhilMiller PhilMiller added the bug label Jun 7, 2024
@PhilMiller PhilMiller self-assigned this Jun 7, 2024
@PhilMiller
Copy link
Member Author

The seemingly natural solution to this would be to replace the macros with

const static int BMI_SUCCESS = 0;
const static int BMI_FAILURE = 1;

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
1 participant