Skip to content

Commit d566226

Browse files
committed
#380 Fix compilation error and logic bug in mosaic_util.nc
This change resolves a build failure in mosaic_util.c where a static const double array (m[3][3])was being initialized with variables calculated at runtime. Standard C requires static variables to be initialized with compile-time constants, which caused GCC to throw an "initializer element is not constant" error. Removing the static keyword not only fixes the compilation issue but also corrects a likely logic bug. As an automatic local variable, the rotation matrix will now accurately populate with fresh, updated values on every function call, ensuring mathematical correctness and thread safety.
1 parent 0fe3e5a commit d566226

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

lib/libfrencutils/mosaic_util.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1691,13 +1691,13 @@ int crosses_pole(const double x[] , int n) {
16911691
void set_the_rotation_matrix() {
16921692
static const double is2 = 1.0 /M_SQRT2;
16931693

1694-
static const double m00 = 0;
1695-
static const double m01 = - is2;
1696-
static const double m02 = is2;
1697-
static const double m11 = 1.0/2;
1698-
static const double m12 = 0.5;
1694+
const double m00 = 0;
1695+
const double m01 = - is2;
1696+
const double m02 = is2;
1697+
const double m11 = 1.0/2;
1698+
const double m12 = 0.5;
16991699

1700-
static const double m[3][3] = { {m00, m01, m02}, {m02, m11, m12},{m01, m12, m11} };
1700+
const double m[3][3] = { {m00, m01, m02}, {m02, m11, m12},{m01, m12, m11} };
17011701

17021702
for (int i = 0; i < 3; i++) {
17031703
for (int j = 0; j < 3; j++) {

0 commit comments

Comments
 (0)