Skip to main content
gamedev.net
🔒 Locked

address

Started by Tiger99 1 reply 200+ views
Original Post
Tiger99
Tiger99
Hello All I am wondering how can I get the address of a function and an array? for example if I need the address of function PCB() Can I do &PCB array: PCB[255] Can I do &PCB Thanks
Kosmo
Kosmo
If you have array defined like
dword someArray[100];

someArray contains the pointer to the first member of array.

for function pointers go to:
www.function-pointer.org

Vikke Matikainen
Vikke Matikainen
Wyrframe
Wyrframe

  
typedef int (*FuncType)( long param1, long param2 );
#define FUNCBUILDER( X ) int X ( long param1, long param2 )

FuncType FunctionArray[256];

// I use the macro FUNCBUILDER for this, especially for

// script-accessible function writing.

FUNCBUILDER( MyFunction );

FUNCBUILDER( MyFunction ) {
return (param1 + param2) * 2;
}

// The above macros expand to this code exactly.

int MyFunction( long param1, long param2 );

int MyFunction( long param1, long param2 ) {
return (param1 + param2) * 2;
}


void main( void ) {
int myReturn;

// This syntax works... I've tried it with Borland's 32-bit

// C++ Builder version 5.5, and with MSVC++ 6.0.

FunctionArray[0] = MyFunction;

// Henceforth, these are identical calls.

myReturn = (FunctionArray[0])( (long)23, (long)100 );
myReturn = MyFunction( (long)23, (long)100 );
}


Also, follow the link Kosmo gave; I've been there. It helps.

[edited by - Wyrframe on March 21, 2003 9:46:24 PM]
RIP GameDev.net: launched 2 unusably-broken forum engines in as many years, and now has ceased operating as a forum at all, happy to remain naught but an advertising platform with an attached social media presense, headed by a staff who by their own admission have no idea what their userbase wants or expects.Here's to the good times; shame they exist in the past.

Topic Locked

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

Sign in to reply to this topic.