charmedlabs / pixy

pixy CMUcam5
Other
337 stars 242 forks source link

GCC>4.5 - error: taking address of temporary array #2

Closed kobaan closed 10 years ago

kobaan commented 10 years ago

To fix this error with GCC>4.5:

g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++-64 -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I../libpixy -I. -I. -o clut.o clut.cpp clut.cpp: In function ‘double\ plotcluster(uint32t, int)’: clut.cpp:82:98: error: taking address of temporary array clut.cpp:87:103: error: taking address of temporary array clut.cpp:98:55: error: taking address of temporary array clut.cpp: In function ‘double iterateline(double, double, int, double_, double, double)’: clut.cpp:192:81: error: taking address of temporary array

Please apply this patch:

--- clut.cpp.orig   2013-11-19 13:51:02.492603070 +0100
+++ clut.cpp    2013-11-19 14:40:15.991826934 +0100
@@ -79,12 +79,13 @@
     double lp[] = {ps, slope*meanx-ps*meanx};

     // Find upper and lower major lines
-    double yu = iterateline(ppp1, ppp2, d_len/3, (double []){slope, 0}, fabs(0.001/cos(angle)), e);
+    double li[] = {slope, 0};
+    double yu = iterateline(ppp1, ppp2, d_len/3, li, fabs(0.001/cos(angle)), e);

     yu = yu + fabs(d * yu);
     double lu[] = {slope, yu};

-    double yd = iterateline(ppp1, ppp2, d_len/3, (double []){slope, 0}, -1.0*fabs(0.001/cos(angle)), e);
+    double yd = iterateline(ppp1, ppp2, d_len/3, li, -1.0*fabs(0.001/cos(angle)), e);

     yd = yd - fabs(d*yd);
     double ld[] = {slope, yd};
@@ -95,7 +96,9 @@
     yl = yl + -1*sign(uv[1])*fabs(d2*(yl-lp[1]));
     double xxl = yl / (slope-ps);
     double yyl = xxl * slope;
-    double sat = dot_1dim(uv, (double []){xxl, yyl}, 2);
+
+    double arr2[] = {xxl, yyl};
+    double sat = dot_1dim(uv, arr2, 2);
     if (sat < minsat)
     {
        double minl[] = {uv[0]*minsat, uv[1]*minsat};
@@ -189,7 +192,8 @@

     while (1)
     {
-        double btest = boundtest(P0, P1, P_len, (double []) {LI[0], ret}, d_sign);
+   double li2[] = {LI[0], ret};
+        double btest = boundtest(P0, P1, P_len, li2, d_sign);
         double temp = (btest/double(P_len));

         if (temp >= e)
richlegrand commented 10 years ago

nice--- thanks Kobaan!

the code is in a messy and unfinished state, so apologies upfront...

thanks! --rich

On Tue, Nov 19, 2013 at 7:44 AM, kobaan notifications@github.com wrote:

To fix this error with GCC>4.5:

g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++-64 -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I../libpixy -I. -I. -o clut.o clut.cpp clut.cpp: In function ‘double\ plotcluster(uint32t, int)’: clut.cpp:82:98: error: taking address of temporary array clut.cpp:87:103: error: taking address of temporary array clut.cpp:98:55: error: taking address of temporary array clut.cpp: In function ‘double iterateline(double, double, int, double_, double, double)’: clut.cpp:192:81: error: taking address of temporary array

Please apply this patch:

--- clut.cpp.orig 2013-11-19 13:51:02.492603070 +0100 +++ clut.cpp 2013-11-19 14:40:15.991826934 +0100 @@ -79,12 +79,13 @@ double lp[] = {ps, slope_meanx-ps_meanx};

// Find upper and lower major lines

  • double yu = iterateline(ppp1, ppp2, d_len/3, (double []){slope, 0}, fabs(0.001/cos(angle)), e);
  • double li[] = {slope, 0};

    double yu = iterateline(ppp1, ppp2, d_len/3, li, fabs(0.001/cos(angle)), e);

    yu = yu + fabs(d * yu);

    double lu[] = {slope, yu};

    double yd = iterateline(ppp1, ppp2, d_len/3, (double []){slope, 0},

    -1.0*fabs(0.001/cos(angle)), e);

    double yd = iterateline(ppp1, ppp2, d_len/3, li, -1.0*fabs(0.001/cos(angle)), e);

    yd = yd - fabs(d_yd); double ld[] = {slope, yd}; @@ -95,7 +96,9 @@ yl = yl + -1_sign(uv[1])fabs(d2(yl-lp[1])); double xxl = yl / (slope-ps); double yyl = xxl * slope;

    • double sat = dot_1dim(uv, (double []){xxl, yyl}, 2); +
  • double arr2[] = {xxl, yyl};

    double sat = dot_1dim(uv, arr2, 2); if (sat < minsat) { double minl[] = {uv[0]_minsat, uv[1]_minsat}; @@ -189,7 +192,8 @@

    while (1) {

    • double btest = boundtest(P0, P1, P_len, (double []) {LI[0], ret}, d_sign);
  • double li2[] = {LI[0], ret};

    double btest = boundtest(P0, P1, P_len, li2, d_sign); double temp = (btest/double(P_len));

    if (temp >= e)

— Reply to this email directly or view it on GitHubhttps://github.com/charmedlabs/pixy/issues/2 .

Charmed Labs www.charmedlabs.com

ekiwi commented 10 years ago

This issue seems to be fixed. I think you can close it.

kobaan commented 10 years ago

You're right as the code in clut.cpp isn't used anymore. Issue closed.