Skip to main content
GameDev.net gamedev.net
🔒 Locked

extern "c" Question.

Started by Ancient Spirit Oct 24, 2005 at 11:08 AM 3 replies 450+ views
Original Post
Ancient Spirit
Ancient Spirit
I have encountered this syntex latly... I don't know what that means, all i know is that i can combine ASM, FORTRAN and other function to a c++ header file with it... Can someone explain please? thanks in advance.
This world is ruled by big furry CATS!! :)Meow! :)
Ancient Spirit
Ancient Spirit
and how do i link ASM functions or FORTRAN to it?
This world is ruled by big furry CATS!! :)Meow! :)
eviltwigflipper
eviltwigflipper
Since I don't know exactlly what you doing, but if your using c++/C you just embed your asm inside of a function. I don't believe you can do it with fortran though.

Example

int my_asm_function( void ) {    int a = 0;    _asm {       handle A with asm    }    return a;}[/SOURCE]
nmi
nmi
Quote:
Original post by Ancient Spirit
and how do i link ASM functions or FORTRAN to it?


You can create an assembler file, assemble it (i.e. with nasm) to get an object file, then link that file to your application. (This also works with other languages like fortran.)
To be able to call the function you declare it like:
extern "C" void foo(int param);

Make sure that your assembler function uses the correct calling convention for your compiler.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.