@@ -105,17 +105,36 @@ endfunction(GR_SWIG_MAKE_DOCS)
105
105
macro (GR_SWIG_MAKE name )
106
106
set (ifiles ${ARGN} )
107
107
108
- # Shimming this in here to take care of a SWIG bug with handling
109
- # vector<size_t> and vector<unsigned int> (on 32-bit machines) and
110
- # vector<long unsigned int> (on 64-bit machines). Use this to test
111
- # the size of size_t, then set SIZE_T_32 if it's a 32-bit machine
112
- # or not if it's 64-bit. The logic in gr_type.i handles the rest.
113
- INCLUDE (CheckTypeSize)
114
- CHECK_TYPE_SIZE("size_t" SIZEOF_SIZE_T)
115
- CHECK_TYPE_SIZE("unsigned int" SIZEOF_UINT)
116
- if (${SIZEOF_SIZE_T} EQUAL ${SIZEOF_UINT} )
117
- list (APPEND GR_SWIG_FLAGS -DSIZE_T_32)
118
- endif (${SIZEOF_SIZE_T} EQUAL ${SIZEOF_UINT} )
108
+ # Take care of a SWIG < 3.0 bug with handling std::vector<size_t>,
109
+ # by mapping to the correct sized type on the runtime system, one
110
+ # of "unsigned int", "unsigned long", or "unsigned long long".
111
+ # Compare the sizeof(size_t) with the sizeof the other types, and
112
+ # pick the first one in the list with the same sizeof. The logic
113
+ # in gnuradio-runtime/swig/gr_types.i handles the rest. It is
114
+ # probably not necessary to do this assignment all of the time,
115
+ # but it's easier to do it this way than to figure out the
116
+ # conditions when it is necessary -- and doing it this way won't
117
+ # hurt. This bug seems to have been fixed with SWIG >= 3.0, and
118
+ # mostly happens when not doing a native build (e.g., on Mac OS X
119
+ # when using a 64-bit CPU but building for 32-bit).
120
+
121
+ if (SWIG_VERSION VERSION_LESS "3.0.0" )
122
+ include (CheckTypeSize)
123
+ check_type_size("size_t" SIZEOF_SIZE_T)
124
+ check_type_size("unsigned int" SIZEOF_UINT)
125
+ check_type_size("unsigned long" SIZEOF_UL)
126
+ check_type_size("unsigned long long" SIZEOF_ULL)
127
+
128
+ if (${SIZEOF_SIZE_T} EQUAL ${SIZEOF_UINT} )
129
+ list (APPEND GR_SWIG_FLAGS -DSIZE_T_UINT)
130
+ elseif (${SIZEOF_SIZE_T} EQUAL ${SIZEOF_UL} )
131
+ list (APPEND GR_SWIG_FLAGS -DSIZE_T_UL)
132
+ elseif (${SIZEOF_SIZE_T} EQUAL ${SIZEOF_ULL} )
133
+ list (APPEND GR_SWIG_FLAGS -DSIZE_T_ULL)
134
+ else ()
135
+ message (FATAL_ERROR "GrSwig: Unable to find replace for std::vector<size_t>; this should never happen!" )
136
+ endif ()
137
+ endif ()
119
138
120
139
#do swig doc generation if specified
121
140
if (GR_SWIG_DOC_FILE)
0 commit comments