Skip to content

Commit

Permalink
Add parentheses around macro expressions
Browse files Browse the repository at this point in the history
Things like

    #define NUM_PRIM         NVAR-1

is error prone. For example, `N - NUM__PRIM` will become `N - NVAR - 1`
instead of `N - (NVAR - 1)`.
  • Loading branch information
WeiqunZhang committed Sep 26, 2023
1 parent 70cd484 commit c26f817
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions Source/IndexDefines.H
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef _INDEX_DEFINES_H_
#define _INDEX_DEFINES_H_
#ifndef ROMSX_INDEX_DEFINES_H_
#define ROMSX_INDEX_DEFINES_H_

#include <AMReX_REAL.H>
#include <AMReX_Arena.H>
Expand All @@ -18,10 +18,10 @@
#endif

// Cell-centered primitive variables
#define PrimTheta_comp Temp_comp -1
#define PrimScalar_comp RhoScalar_comp-1
#define PrimTheta_comp (Temp_comp -1)
#define PrimScalar_comp (RhoScalar_comp-1)

#define NUM_PRIM NVAR-1
#define NUM_PRIM (NVAR-1)
#define NGROW 2

namespace BCVars {
Expand Down
12 changes: 6 additions & 6 deletions Source/ROMSX_Constants.H
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef _CONSTANTS_H_
#define _CONSTANTS_H_
#ifndef ROMSX_CONSTANTS_H_
#define ROMSX_CONSTANTS_H_

#include <AMReX_REAL.H>

Expand All @@ -15,9 +15,9 @@ constexpr amrex::Real PI = 3.14159265358979323846264338327950288;
#define CONST_GRAV 9.81

// Derived Constants
#define ip_0 1./p_0
#define iR_d 1./R_d
#define iGamma 1./Gamma
#define rdOcp R_d/c_p
#define ip_0 (1./p_0)
#define iR_d (1./R_d)
#define iGamma (1./Gamma)
#define rdOcp (R_d/c_p)

#endif

0 comments on commit c26f817

Please sign in to comment.