for some reason my program wont let me use my identifiers. They are defined in the header file and the .h is included in my cpp but it wont let me preform operations with them. Does anyone know why this might be? Ive never used these before so its most likely user error just cant figure it out.
#identifier M_PI is undefined
32 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.
M_PI is not a standard thing
isnt it recognized as the value of pi
no
on some compilers yes
but it's non-standard
so you can't rely on it being there
i guess whatever compiler you're using atm doesn't define it
ohh, so whats the point of defining it at the top then
so thing it
you really shouldn't use #define for stuff like this
macros are really terrible
what would be better?
for example
best make it constexpr, not just const
C++20 added standard math constants
so if you can use C++20, you can use std::numbers::pi_v<double>
#include <numbers>
Thank you!
np
@still rose Has your question been resolved? If so, run !solved :)
!solved