    # File lib/ffi/tools/const_generator.rb, line 106
        def calculate(options = {})
          binary = File.join Dir.tmpdir, "rb_const_gen_bin_#{Process.pid}"

          Tempfile.open("#{@prefix}.const_generator") do |f|
            @includes.each do |inc|
              f.puts "#include <#{inc}>"
            end
            f.puts "\nint main(int argc, char **argv)\n{"

            @constants.each_value do |const|
              f.puts "#ifdef \#{const.name}\nprintf(\"\#{const.name} \#{const.format}\\\\n\", \#{const.cast}\#{const.name});\n#endif\n"
            end

            f.puts "\n\treturn 0;\n}"
            f.flush

            output = `gcc #{options[:cppflags]} -D_DARWIN_USE_64_BIT_INODE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -x c -Wall -Werror #{f.path} -o #{binary} 2>&1`

            unless $?.success? then
              output = output.split("\n").map { |l| "\t#{l}" }.join "\n"
              raise "Compilation error generating constants #{@prefix}:\n#{output}"
            end
          end

          output = `#{binary}`
          File.unlink(binary + (FFI::Platform.windows? ? ".exe" : ""))
          output.each_line do |line|
            line =~ /^(\S+)\s(.*)$/
            const = @constants[$1]
            const.value = $2
          end

          missing_constants = @constants.select do |name, constant|
            constant.value.nil?
          end.map { |name,| name }

          if @required and not missing_constants.empty? then
            raise "Missing required constants for #{@prefix}: #{missing_constants.join ', '}"
          end
        end