Skip to content

linesExample: std::sin / std::cos instead of std::sinf / std::cosf - #8609

Merged
danoli3 merged 1 commit into
openframeworks:masterfrom
danoli3:fix-linesexample-cmath
Oct 26, 2026
Merged

danoli3 merged 1 commit into
openframeworks:masterfrom
danoli3:fix-linesexample-cmath

Conversation

@danoli3

@danoli3 danoli3 commented Oct 26, 2026

Copy link
Copy Markdown
Member

Fixes #8607.

examples/graphics/linesExample called std::sinf / std::cosf (7 calls). GCC's <cmath> doesn't declare those in std, so the example didn't compile on Linux. std::sin / std::cos have float overloads, so the result is the same, and they work with every compiler.

Tested on Ubuntu 24.04 aarch64 (GCC 13): linesExample builds. It failed on master ('sinf' is not a member of 'std'), also in the all-examples build in #8605.

@danoli3

danoli3 commented Oct 26, 2026

Copy link
Copy Markdown
Member Author

sinf is C's float version of sin: float in, float out. sin is the double version.

  • std::sin in C++'s is overloaded for float, double and long double. With a float argument it calls the float version and returns float. That's the same precision and the same work as sinf.
  • std::sinf is listed in the C++ standard, but GCC's standard library (libstdc++) didn't declare it in std until GCC 14 (GCC bug 79700). Ubuntu 24.04 ships GCC 13, so std::sinf gives 'sinf' is not a member of 'std'. Clang's libc++ (macOS) and MSVC have had it for years, which is why the example only broke on Linux.

@danoli3
danoli3 merged commit cb742f9 into openframeworks:master Oct 26, 2026
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

Successfully merging this pull request may close these issues.

linesExample doesn't compile on Linux (GCC): std::sinf / std::cosf

1 participant