Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8a36ae9

Browse files
committed
Add check_type functionality to numpy.distutils.
1 parent 9f69bfc commit 8a36ae9

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

numpy/distutils/command/config.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,35 @@ def check_decl(self, symbol,
166166

167167
return self.try_compile(body, headers, include_dirs)
168168

169+
def check_type(self, type_name, headers=None, include_dirs=None,
170+
library_dirs=None):
171+
"""Check type availability. Return True if the type can be compiled,
172+
False otherwise"""
173+
self._check_compiler()
174+
175+
# First check the type can be compiled
176+
body = r"""
177+
int main() {
178+
if ((%(name)s *) 0)
179+
return 0;
180+
if (sizeof (%(name)s))
181+
return 0;
182+
}
183+
""" % {'name': type_name}
184+
185+
st = False
186+
try:
187+
try:
188+
self._compile(body % {'type': type_name},
189+
headers, include_dirs, 'c')
190+
st = True
191+
except distutils.errors.CompileError, e:
192+
st = False
193+
finally:
194+
self._clean()
195+
196+
return st
197+
169198
def check_type_size(self, type_name, headers=None, include_dirs=None, library_dirs=None, expected=None):
170199
"""Check size of a given type."""
171200
self._check_compiler()

0 commit comments

Comments
 (0)