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

collision with new glibc identifier #5203

Closed
100espressos opened this issue Feb 15, 2022 · 3 comments
Closed

collision with new glibc identifier #5203

100espressos opened this issue Feb 15, 2022 · 3 comments

Comments

@100espressos
Copy link

100espressos commented Feb 15, 2022

filament/libs/image/src/ImageSampler.cpp:41:17: error: expected unqualified-id
constexpr float M_PIf = float(filament::math::F_PI);
                ^
/usr/include/math.h:1168:17: note: expanded from macro 'M_PIf'
# define M_PIf          3.14159265358979323846f /* pi */

To reproduce, compile with glibc 2.35+.

References

https://sourceware.org/pipermail/libc-alpha/2022-February/136040.html

<math.h> macros for single-precision float constants are added as a
  GNU extension: M_Ef, M_LOG2Ef, M_LOG10Ef, M_LN2f, M_LN10f, M_PIf,
  M_PI_2f, M_PI_4f, M_1_PIf, M_2_PIf, M_2_SQRTPIf, M_SQRT2f and
  M_SQRT1_2f.

Desktop
Linux

*edit: Closing as these should be caught by CI

@GokulDas027
Copy link

Having the same issue while building filament on Manjaro with core/glibc 2.35-6 . Have you found any workaround for this issue.

@100espressos
Copy link
Author

One workaround is to rename the constant (used only in one file) to something else, like M_PI_f in this diff:

index 98073c489..d8bc32f82 100644
--- a/libs/image/src/ImageSampler.cpp
+++ b/libs/image/src/ImageSampler.cpp
@@ -38,7 +38,7 @@ struct FilterFunction {
     bool rejectExternalSamples = true;
 };
 
-constexpr float M_PIf = float(filament::math::F_PI);
+constexpr float M_PI_f = float(filament::math::F_PI);
 
 const FilterFunction Box {
     .fn = [](float t) { return t <= 0.5f ? 1.0f : 0.0f; },
@@ -50,7 +50,7 @@ const FilterFunction Nearest { Box.fn, 0.0f };
 const FilterFunction Gaussian {
     .fn = [](float t) {
         if (t >= 2.0) return 0.0f;
-        const float scale = 1.0f / std::sqrt(0.5f * M_PIf);
+        const float scale = 1.0f / std::sqrt(0.5f * M_PI_f);
         return std::exp(-2.0f * t * t) * scale;
     },
     .boundingRadius = 2
@@ -86,7 +86,7 @@ const FilterFunction Mitchell {
 // Not bothering with a fast approximation since we cache results for each row.
 float sinc(float t) {
     if (t <= 0.00001f) return 1.0f;
-    return std::sin(M_PIf * t) / (M_PIf * t);
+    return std::sin(M_PI_f * t) / (M_PI_f * t);
 }

@GokulDas027
Copy link

Okay, that works for the immediate need. Thanks.

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