summaryrefslogtreecommitdiff
blob: 23d130f6065024d8cad763d5b4e16ec0d25e1d20 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
From: Christian Kastner <debian@kvr.at>
Date: Thu, 1 Jul 2010 01:02:47 +0200
Subject: [PATCH] Portable handling for va_list

The current code wrongly assumes va_list is always implemented as an array. va_list
however is an opaque type, and may also be implemented as a struct, for
example. This patch implements handling of va_list in a platform-independent
way, fixing a FTBFS on alpha and armel.

Forwarded: no
Last-Update: 2010-07-01
---
 src/include/fann_cpp.h |   21 +++++++++++++++------
 1 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/src/include/fann_cpp.h b/src/include/fann_cpp.h
index eb647af..bf6e75b 100644
--- a/src/include/fann_cpp.h
+++ b/src/include/fann_cpp.h
@@ -916,9 +916,12 @@ public:
         bool create_standard(unsigned int num_layers, ...)
         {
             va_list layers;
+            unsigned int arr[num_layers];
+
             va_start(layers, num_layers);
-            bool status = create_standard_array(num_layers,
-                reinterpret_cast<const unsigned int *>(layers));
+            for (unsigned int ii = 0; ii < num_layers; ii++)
+                arr[ii] = va_arg(layers, unsigned int);
+            bool status = create_standard_array(num_layers, arr);
             va_end(layers);
             return status;
         }
@@ -966,9 +969,12 @@ public:
         bool create_sparse(float connection_rate, unsigned int num_layers, ...)
         {
             va_list layers;
+            unsigned int arr[num_layers];
+
             va_start(layers, num_layers);
-            bool status = create_sparse_array(connection_rate, num_layers,
-                reinterpret_cast<const unsigned int *>(layers));
+            for (unsigned int ii = 0; ii < num_layers; ii++)
+                arr[ii] = va_arg(layers, unsigned int);
+            bool status = create_sparse_array(connection_rate, num_layers, arr);
             va_end(layers);
             return status;
         }
@@ -1013,9 +1019,12 @@ public:
         bool create_shortcut(unsigned int num_layers, ...)
         {
             va_list layers;
+            unsigned int arr[num_layers];
+
             va_start(layers, num_layers);
-            bool status = create_shortcut_array(num_layers,
-                reinterpret_cast<const unsigned int *>(layers));
+            for (unsigned int ii = 0; ii < num_layers; ii++)
+                arr[ii] = va_arg(layers, unsigned int);
+            bool status = create_shortcut_array(num_layers, arr);
             va_end(layers);
             return status;
         }
--