ผมได้ไปอ่านบทความ 5 reasons the D programming language is a great choice for development เจอประเด็นน่าสนใจสองสามประเด็นดังนี้
มีสองวิธีดังนี้
วิธีที่ 1 สร้างไฟล์ .di ขึ้นมาสำหรับใช้เชื่อมโค้ดระหว่างภาษา C++ กับภาษา D
ไฟล์ a.c
ไฟล์ b.d
1142
อ่านเพิ่มเติมได้ที่ http://dlang.org/cpp_interface.html
วิธีที่ 2 ใช้เครื่องมือแปลงโค้ด
เครื่องมือแปลงโค้ด
http://rainers.github.io/visuald/visuald/CppConversion.html
http://dlang.org/htod.html
slides: http://walterbright.com/cppint.pdf
วิธีที่ 1 สร้างไฟล์ .di ขึ้นมาสำหรับใช้เชื่อมโค้ดระหว่างภาษา C++ กับภาษา D
ไฟล์ a.c
int f(int a, int b){ return a + b + 42; }สร้างไฟล์ a.di ขึ้นมา
extern (C): int f(int, int);สร้างไฟล์ภาษา D สำหรับเรียกใช้งานกับโค้ดภาษา C++
ไฟล์ b.d
import std.stdio; import a; void main(){ writeln( f( 100, 1000) ); }ทำการคอมไพล์ไฟล์ a.c
gcc -c a.cคอมไพล์ไฟล์ b.d
dmd b.d a.oผลลัพธ์
1142
อ่านเพิ่มเติมได้ที่ http://dlang.org/cpp_interface.html
วิธีที่ 2 ใช้เครื่องมือแปลงโค้ด
เครื่องมือแปลงโค้ด
http://rainers.github.io/visuald/visuald/CppConversion.html
http://dlang.org/htod.html
slides: http://walterbright.com/cppint.pdf
ความคิดเห็น
แสดงความคิดเห็น