Beginner C/C++

Moderators: None (Apply to moderate this forum)
Number of threads: 5430
Number of posts: 16951

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
problem with a parameter of a function in a DLL. Posted by Juan_jose. on 23 Mar 2006 at 4:00 PM
Hello

I've developed a DLL in delphi, and one of the functions requires a Pointer...

Supossing the Function is AAA()

y tryed doing the next:

int a;
int *a2;

a2 = &a;

AAA(a2);


but it doesn't work, how can i do it??????


I hope you can help me


>juan<
Report
Re: problem with a parameter of a function in a DLL. Posted by stober on 23 Mar 2006 at 9:00 PM
This message was edited by stober at 2006-3-23 21:5:45

: Hello
:
: I've developed a DLL in delphi, and one of the functions requires a Pointer...
:
: Supossing the Function is AAA()
:
: y tryed doing the next:
:
: int a;
: int *a2;
:
: a2 = &a;
:
: AAA(a2);
:
:
: but it doesn't work, how can i do it??????
:
:
: I hope you can help me
:
:
: >juan<
:



how to do in C/C++ it depends on how the function is prototyped.
// function prototype
void AAA(int* ptr);

int a;
// now pass a pointer to function AAA
// its not necessary to use another variable
AAA(&a);


beyond that, I have no clue how to call delphi functions from c, or even if they can be called from c.

When you say "it doesn't work" just what exactly do you mean? is it a compile-time or runtime error? what was the error or behavior?

Maybe (just guessing here) delphi uses the __pascal calling convention? then you need to prototype the function like this

void __pascal AAA(int* ptr);





Report
Re: problem with a parameter of a function in a DLL. Posted by Juan_jose. on 24 Mar 2006 at 3:27 AM
Hi!!!

ok first of all, thank you for answering!!!.
i could slove the probleamm like this:

The function is prototyped: AAA(char *buf)

and then i declare an array:

char ScreenVAR[800*600*2];
char *ScreenP;

ScreenP = &ScreenVAR;

AAA(ScreenP);

===============================
i'm a begginer in C, and i was trying to rewrite my code to it...
in pascal a pointer variable, is like a matrix of bytes... not just a variable pointing to another (but it can be done)

C IS THE GREATEST OF THE GIGH LEVEL LANGUAGE

It gives you more freedom!


Thanke you.

Juan
Report
Re: problem with a parameter of a function in a DLL. Posted by stober on 24 Mar 2006 at 4:27 AM
: Hi!!!
:
: ok first of all, thank you for answering!!!.
: i could slove the probleamm like this:
:
: The function is prototyped: AAA(char *buf)
:
: and then i declare an array:
:
: char ScreenVAR[800*600*2];
: char *ScreenP;
:
: ScreenP = &ScreenVAR;
:
: AAA(ScreenP);
:
it is not necessary to create another variable, all arrays are passed to functions as pointers

char ScreenVAR[800*600*2];
AAA(ScreenVAR);

Report
Re: problem with a parameter of a function in a DLL. Posted by Lundin on 24 Mar 2006 at 3:31 AM
: This message was edited by stober at 2006-3-23 21:5:45

: : Hello
: :
: : I've developed a DLL in delphi, and one of the functions requires a Pointer...
: :
: : Supossing the Function is AAA()
: :
: : y tryed doing the next:
: :
: : int a;
: : int *a2;
: :
: : a2 = &a;
: :
: : AAA(a2);
: :
: :
: : but it doesn't work, how can i do it??????
: :
: :
: : I hope you can help me
: :
: :
: : >juan<
: :
:
:
:
: how to do in C/C++ it depends on how the function is prototyped.
:
: // function prototype
: void AAA(int* ptr);
: 
: int a;
: // now pass a pointer to function AAA
: // its not necessary to use another variable
: AAA(&a);
: 

:
: beyond that, I have no clue how to call delphi functions from c, or even if they can be called from c.
:
: When you say "it doesn't work" just what exactly do you mean? is it a compile-time or runtime error? what was the error or behavior?
:
: Maybe (just guessing here) delphi uses the __pascal calling convention? then you need to prototype the function like this
:
: void __pascal AAA(int* ptr);
:


I think __pascal is something VC++ specific. The PASCAL calling convention from the win api should be used.

void PASCAL AAA(int* ptr);

But PASCAL is probably defined as __stdcall, iirc...
Report
Re: problem with a parameter of a function in a DLL. Posted by stober on 24 Mar 2006 at 4:25 AM
:
:
: I think __pascal is something VC++ specific. The PASCAL calling convention from the win api should be used.
:
: void PASCAL AAA(int* ptr);
:
: But PASCAL is probably defined as __stdcall, iirc...
:


its deprecated in VC++ 2005.



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.