Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikibooksThe Free Textbook Project
Search

C Programming/Mixing languages

From Wikibooks, open books for an open world
<C Programming
Thelatest reviewed version waschecked on16 April 2020. There is1 pending change awaiting review.
Low-level IOC Programming
Mixing languages
GObject

Assembler

[edit |edit source]

SeeEmbedded Systems/Mixed C and Assembly Programming

Cg

[edit |edit source]

Make the main program (for CPU) in C, which loads and run theCg program ( for GPU ).[1][2][3]

Header files

[edit |edit source]

Add to C program:[4]

#include<Cg/cg.h> /* To include the core Cg runtime API into your  program */#include<Cg/cgGL.h>  /* to include the OpenGL-specific Cg runtime API */

Minimal program

[edit |edit source]

Java

[edit |edit source]

Using the Java native interface (JNI), Java applications can call C libraries.

See also

Perl

[edit |edit source]

To mix Perl and C, we can use XS. XS is an interface description file format used to create an extension interface between Perl and C code (or a C library) which one wishes to use with Perl.

The basic procedure is very simple. We can create the necessary subdirectory structure by running "h2xs" application (e.g. "h2xs -A -n Modulename"). This will create - among others - a Makefile.PL, a .pm Perl module and a .xs XSUB file in the subdirectory tree. We can edit the .xs file by adding our code to that, let's say:

voidhello()  CODE:    printf("Hello, world!\n");

and we can successfully use our new command at Perl side, after running a "perl Makefile.PL" and "make".

Further details can be found on theperlxstutperldoc page.

Python

[edit |edit source]

Here can be found some details about extending Python with modules written in C. You might read aboutCython andPyrex as well, that makes easier to create modules in C, translating a Python-like code into C.

This section is a stub.
You can help Wikibooks byexpanding it.

Using the Pythonctypes module, one can write C code directly into Python.

Further reading

[edit |edit source]

References

[edit |edit source]
  1. Lesson: 47 from NeHe Productions
  2. Cg Bumpmapping by Razvan Surdulescu at GameDev
  3. [http://www.fusionindustries.com/default.asp?page=cg-hlsl-faq | Cg & HLSL Shading Language FAQ by Fusion Industries]
  4. http://http.developer.nvidia.com/CgTutorial/cg_tutorial_appendix_b.html NVidia Cg tutorial. Appendix B. The Cg Runtime
  5. Absolutely minimal CG program for good fundamentals understanding
Low-level IOC Programming
Mixing languages
GObject
Retrieved from "https://en.wikibooks.org/w/index.php?title=C_Programming/Mixing_languages&oldid=4595840"
Categories:

[8]ページ先頭

©2009-2025 Movatter.jp