Method: MakeMakefile#check_signedness
- Defined in:
- lib/mkmf.rb
#check_signedness(type, headers = nil, opts = nil, &b) ⇒ Object
Returns the signedness of the given type. You may optionally specify
additional headers to search in for the type.
If the type is found and is a numeric type, a macro is passed as a
preprocessor constant to the compiler using the type name, in uppercase,
prepended with SIGNEDNESS_OF_, followed by the type name, followed by
=X where "X" is positive integer if the type is unsigned
and a negative integer if the type is signed.
For example, if size_t is defined as unsigned, then
check_signedness('size_t') would return +1 and the
SIGNEDNESS_OF_SIZE_T=+1 preprocessor macro would be passed to
the compiler. The SIGNEDNESS_OF_INT=-1 macro would be set
for check_signedness('int')
1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 |
# File 'lib/mkmf.rb', line 1331 def check_signedness(type, headers = nil, opts = nil, &b) typedef, member, prelude = typedef_expr(type, headers) signed = nil checking_for("signedness of #{type}", STRING_OR_FAILED_FORMAT) do signed = try_signedness(typedef, member, [prelude], opts, &b) or next nil $defs.push("-DSIGNEDNESS_OF_%s=%+d" % [type.tr_cpp, signed]) signed < 0 ? "signed" : "unsigned" end signed end |