ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
#define ON 0
#define DFLT_BORDER 2 /* default border of image */
#if defined(WIN32)
//#define PI (3.141592653589793)
//#define PI (3.1415926536)
#endif
#define PID2 1.5707963268
#define TAN_TOO_BIG 263.0 /* tan so big that angle is PI/2 */
#define INBOUNDX(X) ((X) >= 0 && (X) < width)
#define INBOUNDY(Y) ((Y) >= 0 && (Y) < height)
int usage (short);
int input (int, char **, long *, short *);
main (argc, argv)
int argc;
char *argv[];
{
Image *imgI, *imgH; /* I/O image structures */
unsigned char **imgIn, **hough; /* input/output images */
int width, height; /* input image size */
long border; /* zero out border of image */
short dFlag; /* if = 0, display peak in Hough space */
long xEnd, yEnd; /* end of image within borders */
long thetaHt, rhoWid; /* width and height of Hough space */
long rhoWidM1; /* rho width minus 1 */
double rho, theta; /* radius and angle in Hough space */
double tanTheta; /* tan of theta angle */
double denom; /* denominator */
double rhoNorm; /* normalization factor for rho */
int max, xMax, yMax; /* peak point in Hough space */
double x1, y1;
long i, j;
long x, y;
if ((input (argc, argv, &border, &dFlag)) < 0)
return (-1);
/* open input and output images */
imgI = ImageIn (argv[1]);
imgIn = imgI->img;
height = ImageGetHeight (imgI);
width = ImageGetWidth (imgI);
printf ("image size is %dx%d.\n", width, height);
int
input (argc, argv, border, dFlag)
int argc;
char *argv[];
long *border; /* zero out border of image */
short *dFlag; /* if = 1, display peak */
{
long n;
if (argc == 1)
USAGE_EXIT (1);
if (argc == 2)
USAGE_EXIT (0);
*dFlag = 0;
*border = DFLT_BORDER;
for (n = 3; n < argc; n++) {
if (strcmp (argv[n], "-b") == 0) {
if (++n == argc || argv[n][0] == '-')
USAGE_EXIT (0);
*border = atol (argv[n]);
}
else if (strcmp (argv[n], "-d") == 0)
*dFlag = 1;
else if (strcmp (argv[n], "-L") == 0) {
print_sos_lic ();
exit (0);
}
else
USAGE_EXIT (0);
}
Declare PI similarly as it was for the case for WIN32, but do something like this:
Code:
#ifndef PI
#define PI (3.141592653589793)
#endif
Are you using -lm "dash ell em" in your link to include the math library in your link? I don't think you'd get this particular error by not having your link line correct though, because it is a syntax error versus a linker error.
Perform your make with debug enabled so you can see the chosen math.h file which is being referenced and check that file for inclusion of PI. If you still feel PI is declared in that file, try injecting an intentional syntax error into that math.h file near the top to prove that it is the referenced file and to verify that a syntax error will break your compile. Next I'd move near the definition of PI in that math.h file, verify that any conditional flags are allowing the parse to get there, also introducing intentional syntax errors at that point in the file. If all proves out, the math.h you think is being referenced is referenced and you can cause a syntax error right on the PI declaration line and cause the compilation to fail, then go back to your source. Immediately after the inclusion of math.h, put in an intentional fail for the declaration and non-declaration of PI, such as:
Code:
#include <math.h>
#ifdef PI
cause compiler error 1
#else
cause compiler error 2
#endif
In either case, it should fail one or the other of those. Ideally it would complain on the error 1 line which means the inclusion of math.h worked and then something lower in your file is negating it.
There's some sort of misunderstanding as to which math.h your accessing, or something happening yet unknown, but this should work and work correctly. These are just some ideas to run that problem to ground.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.