ISO C++ forbids variable-size array at line 172, 173, and 174. Variable-sized arrays are a gnu extension and breaks portability.
Fix: use std::vector
--- ../../zm-0.9.16.ORIG/src/zmc.cpp 2003-07-04 05:31:33.000000000 -0700
+++ zmc.cpp 2004-01-05 21:18:41.000000000 -0800
@@ -17,6 +17,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
+#include <vector>
#include <getopt.h>
#include <signal.h>
#include <values.h>
@@ -169,9 +170,9 @@
monitors[0]->PreCapture();
}
- long capture_delays[n_monitors];
- long next_delays[n_monitors];
- struct timeval last_capture_times[n_monitors];
+ std::vector<long> capture_delays(n_monitors);
+ std::vector<long> next_delays(n_monitors);
+ std::vector<struct timeval> last_capture_times(n_monitors);
for ( int i = 0; i < n_monitors; i++ )
{
last_capture_times[i].tv_sec = last_capture_times[i].tv_usec = 0;
ISO C++ standard violation in zmc.cpp
- zoneminder
- Site Admin
- Posts: 5215
- Joined: Wed Jul 09, 2003 2:07 pm
- Location: Bristol, UK
- Contact:
Re: ISO C++ standard violation in zmc.cpp
Hi Ian,
Thanks for these, I am checking them as I see them and will implement and/or comment once I've finished my current development effort and can apply the changes stanadalone.
Cheers,
Phil,
Thanks for these, I am checking them as I see them and will implement and/or comment once I've finished my current development effort and can apply the changes stanadalone.
Cheers,
Phil,
- zoneminder
- Site Admin
- Posts: 5215
- Joined: Wed Jul 09, 2003 2:07 pm
- Location: Bristol, UK
- Contact:
Re: ISO C++ standard violation in zmc.cpp
Hi Ian,
I did actually try this one but had a couple of problems. The first is that it grumbled about vector.h not being part of package 'std' and the second was that I can't see how your patch actually defines (a) what additional header to include and also what the types of the includes are. I suspect this is because '<' are being interpreted as HTML by the forum software so maybe you could mail it to me direct and I will try it then. I used to use template libraries a lot until I realized how much code bloat they introduce but I'll give them another go!
Cheers,
Phil,
I did actually try this one but had a couple of problems. The first is that it grumbled about vector.h not being part of package 'std' and the second was that I can't see how your patch actually defines (a) what additional header to include and also what the types of the includes are. I suspect this is because '<' are being interpreted as HTML by the forum software so maybe you could mail it to me direct and I will try it then. I used to use template libraries a lot until I realized how much code bloat they introduce but I'll give them another go!
Cheers,
Phil,
Re: ISO C++ standard violation in zmc.cpp
Heh... I'll just e-mail you about any future patches.. I've actually got a TON more that'll make your code compile w/o warnings under -W -Wall -pedantic and a few others that I can't remember right now.
just include with vector (no .h)
I did notice however that when I compiled with that mod, things didn't quite work correctly, so I actually changed that over to using something like:
- long capture_delays[n_monitors];
+ long *capture_delays = new long[n_monitors];
...
+ delete [] capture_deplays;
just include with vector (no .h)
I did notice however that when I compiled with that mod, things didn't quite work correctly, so I actually changed that over to using something like:
- long capture_delays[n_monitors];
+ long *capture_delays = new long[n_monitors];
...
+ delete [] capture_deplays;