RM大富翁 – 晴兰的秘密社团 https://seiran.mist.so Ruby与RGSS研究 Tue, 15 Jan 2019 10:09:01 +0000 zh-CN hourly 1 https://wordpress.org/?v=4.9.5 [RM大富翁]Experimental Preview https://seiran.mist.so/richmachine/expreview.html https://seiran.mist.so/richmachine/expreview.html#respond Thu, 18 Oct 2012 23:59:21 +0000 http://seiran.9bu.org/?p=17 1.LLVM X TCC

clang作为C++前端的速度还是比gcc快那么一些的,嘛~而且人家是BSD-like的授权

$TEST=false
if $TEST
 LTCC = "E:\llvmas\ltcc"
 def runcpp(cppcode)
  open("1.cpp", "w"){|f|
    f.write cppcode
  }
  system "#{LTCC} 1.cpp 1.exe"
  system "1.exe"
 end

 def getdll(cppcode, dllname)
   open("1.cpp", "w"){|f|
    f.write cppcode
  }
  system "cmd /c #{LTCC} 1.cpp #{dllname} -rdynamic -shared"
 end

 runcpp("
 #include <windows.h>
 int main(){
   MessageBox(0, "Hello", 0, 0);
 }")

 getdll(<<-'EOF', "mydll.dll")
   extern "C" int add(int a, int b){
     return a+b;
   }
 EOF

 p Win32API.new('mydll.dll', 'add', 'ii', 'i').call(3, 5)
end

 

]]>
https://seiran.mist.so/richmachine/expreview.html/feed 0