From 5c96c8c1b3da36e7f31427185bb3b4403df8bb04 Mon Sep 17 00:00:00 2001
From: pixhawk <vilhjalmur89@gmail.com>
Date: Thu, 26 Jan 2017 11:27:42 +0100
Subject: [PATCH] Removed std::fill_n since it is not supported

---
 src/modules/commander/mag_calibration.cpp | 26 +++++++++++------------
 1 file changed, 12 insertions(+), 14 deletions(-)

diff --git a/src/modules/commander/mag_calibration.cpp b/src/modules/commander/mag_calibration.cpp
index 863e87e121..83361472e9 100644
--- a/src/modules/commander/mag_calibration.cpp
+++ b/src/modules/commander/mag_calibration.cpp
@@ -51,7 +51,6 @@
 #include <string.h>
 #include <poll.h>
 #include <cmath>
-#include <algorithm>
 #include <fcntl.h>
 #include <drivers/drv_hrt.h>
 #include <drivers/drv_accel.h>
@@ -602,27 +601,26 @@ calibrate_return mag_calibrate_all(orb_advert_t *mavlink_log_pub)
 	float sphere_x[max_mags];
 	float sphere_y[max_mags];
 	float sphere_z[max_mags];
-	std::fill_n(sphere_x, max_mags, 0.0f);
-	std::fill_n(sphere_y, max_mags, 0.0f);
-	std::fill_n(sphere_z, max_mags, 0.0f);
-
 	float sphere_radius[max_mags];
-	std::fill_n(sphere_radius, max_mags, 0.2f);
-
 	float diag_x[max_mags];
 	float diag_y[max_mags];
 	float diag_z[max_mags];
-	std::fill_n(diag_x, max_mags, 1.0f);
-	std::fill_n(diag_y, max_mags, 1.0f);
-	std::fill_n(diag_z, max_mags, 1.0f);
-
 	float offdiag_x[max_mags];
 	float offdiag_y[max_mags];
 	float offdiag_z[max_mags];
-	std::fill_n(offdiag_x, max_mags, 0.0f);
-	std::fill_n(offdiag_y, max_mags, 0.0f);
-	std::fill_n(offdiag_z, max_mags, 0.0f);
 
+	for (unsigned cur_mag = 0; cur_mag < max_mags; cur_mag++) {
+		sphere_x[cur_mag] = 0.0f;
+		sphere_y[cur_mag] = 0.0f;
+		sphere_z[cur_mag] = 0.0f;
+		sphere_radius[cur_mag] = 0.2f;
+		diag_x[cur_mag] = 1.0f;
+		diag_y[cur_mag] = 1.0f;
+		diag_z[cur_mag] = 1.0f;
+		offdiag_x[cur_mag] = 0.0f;
+		offdiag_y[cur_mag] = 0.0f;
+		offdiag_z[cur_mag] = 0.0f;
+	}
 
 	// Sphere fit the data to get calibration values
 	if (result == calibrate_return_ok) {
-- 
GitLab