ensure M_PI is defined
Some image manipulation functions use trigonometric functions. This includes using the number Pi. Pi is often available as M_PI via including <math.h>. This constant is part of the Unix98 standard, not the C standard itself. According to the GCC documentation[1], M_PI is only defined when the feature selection macro _XOPEN_SOURCE=500 is used. This seems to be default in many versions of GNU/Linux, since ssocr could always use M_PI without explicitly setting _XOPEN_SOURCE=500. An MPlayer bug report[2] reported a build failure because M_PI was not defined. This lead to a patch[3] to work around this problem. I want to avoid running into this specific problem in the future, without introducing significant changes to ssocr. Thus I check if M_PI is defined after inlcuding <math.h>, and define it myself if it is missing. I use the value found in /usr/include/math.h from GNU Libc on my current system (Ubuntu GNU/Linux 20.04.6 LTS). [1] https://www.gnu.org/software/libc/manual/html_node/Mathematical-Constants.html [2] https://trac.mplayerhq.hu/ticket/2423 [3] https://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/2024-December/074244.html Also add '+' to the version number to indicate changes after the latest release.
This commit is contained in:
@@ -23,7 +23,7 @@
|
||||
#define SSOCR2_DEFINES_H
|
||||
|
||||
/* version number */
|
||||
#define VERSION "2.24.1"
|
||||
#define VERSION "2.24.1+"
|
||||
|
||||
/* states */
|
||||
#define FIND_DARK 0
|
||||
|
||||
@@ -27,8 +27,11 @@
|
||||
/* string manipulation */
|
||||
#include <string.h> /* strcasecmp, strcmp, strrchr */
|
||||
|
||||
/* sin, cos */
|
||||
#include <math.h>
|
||||
/* trigonometry */
|
||||
#include <math.h> /* sin, cos, M_PI */
|
||||
#ifndef M_PI /* sometimes, M_PI is not defined */
|
||||
#define M_PI 3.14159265358979323846
|
||||
#endif
|
||||
|
||||
/* my headers */
|
||||
#include "defines.h" /* defines */
|
||||
|
||||
Reference in New Issue
Block a user