Home > Back-end >  How the DELPHI function into a C statement?
How the DELPHI function into a C statement?

Time:09-24

I joined in the c + + BUILDER projects a DELPHI. Pas module,
Want to use the function directly (because the code is more complex, don't want to switch to c + + code),

DELPHI in the cell definition:
The unit OleComCall;
Implementation
The function GridOut (datFile: string; GrdFile: string; BmpFile: string) : integer;

In c + + BUILDER:
Int _pascal GridOut (String datFile, String grdFile, String bmpFile);

Compile, but the connection, however, show unreoleved fuction...

Don't know what is wrong statement or other problems, ask ace to give directions how to implement the code sharing?

CodePudding user response:

It should be:

 extern "C" int __fastcall GridOut (* grdFile * datFile String, the String, the String * bmpFile); 

CodePudding user response:

reference 1st floor FASM_FASM response:
should be:

 extern "C" int __fastcall GridOut (* grdFile * datFile String, the String, the String * bmpFile); 


BTW:

C + + builder can use pas unit, need to add pas unit of file used to engineering, but there is a problem, c + + builder does not generate c + + the HPP header files needed to immediately, when the reference code in a unit of pas is no completion, separate compilation also complains that say "so-and-so is not defined", there is a little skill, pas unit file after joining project, to BUILD a first, will the project to BUILD again, not make, don't tube can pass, when the IDE is called related program compile pas unit at a time, generate HPP header file, you can normal reference unit is one of the content of pas HPP generated file not artificial, change to the c + + builder maintenance is ok, if you modify the pas in the cell definition, to BUILD again, HPP file is updated,

CodePudding user response:

The. Directly to the pas files added to the c + + Builder project, the IDE will automatically generate the corresponding header file at compile time,

CodePudding user response:

reference 1st floor FASM_FASM response:
should be:

 extern "C" int __fastcall GridOut (* grdFile * datFile String, the String, the String * bmpFile); 


This why extern "C"? Way of c + + compiler?

CodePudding user response:

U010165006
reference 4 floor response:
Quote: refer to 1st floor FASM_FASM response:

It should be:

 extern "C" int __fastcall GridOut (* grdFile * datFile String, the String, the String * bmpFile); 


This why extern "C"? Way of c + + compiler?


The only emphasis on the function symbol name is C way rather than the way of C + + (C + + name after beating will be like? GridOut @ 12 @ @ _NN this name, depending on the compiler),

CodePudding user response:

reference 5 floor FASM_FASM reply:
Quote: refer to 4th floor u010165006 response:

Quote: refer to 1st floor FASM_FASM response:

It should be:

 extern "C" int __fastcall GridOut (* grdFile * datFile String, the String, the String * bmpFile); 


This why extern "C"? Way of c + + compiler?


The only emphasis on the function symbol name is C way rather than the way of C + + (C + + name after beating will be like? GridOut @ 12 @ @ _NN this name, depending on the compiler),


I mean the use of the function in the PAS in CB should be declared as extern "C"?
PAS function String datFile parameters to CB is the pointer?

CodePudding user response:

refer to 6th floor u010165006 response:
Quote: refer to the fifth floor FASM_FASM reply:

Quote: refer to 4th floor u010165006 response:

Quote: refer to 1st floor FASM_FASM response:

It should be:

 extern "C" int __fastcall GridOut (* grdFile * datFile String, the String, the String * bmpFile); 


This why extern "C"? Way of c + + compiler?


The only emphasis on the function symbol name is C way rather than the way of C + + (C + + name after beating will be like? GridOut @ 12 @ @ _NN this name, depending on the compiler),


I mean the use of the function in the PAS in CB should be declared as extern "C"?
PAS function String datFile parameters to CB is the pointer?


refer to 6th floor u010165006 response:
Quote: refer to the fifth floor FASM_FASM reply:

Quote: refer to 4th floor u010165006 response:

Quote: refer to 1st floor FASM_FASM response:

It should be:

 extern "C" int __fastcall GridOut (* grdFile * datFile String, the String, the String * bmpFile); 


This why extern "C"? Way of c + + compiler?


The only emphasis on the function symbol name is C way rather than the way of C + + (C + + name after beating will be like? GridOut @ 12 @ @ _NN this name, depending on the compiler),


I mean the use of the function in the PAS in CB should be declared as extern "C"?
PAS function String datFile parameters to CB is the pointer?


Not ah, I said is a global function, object methods, it is not, c + + builder has special expansion with Delphi interface keyword (ordinary c + + compiler doesn't recognize),
In the Delphi object instance is corresponding to the c + + is a pointer,

CodePudding user response:

refer to 7th floor FASM_FASM response:
Quote: refer to the sixth floor u010165006 response:

Quote: refer to the fifth floor FASM_FASM reply:

Quote: refer to 4th floor u010165006 response:

Quote: refer to 1st floor FASM_FASM response:

It should be:

 extern "C" int __fastcall GridOut (* grdFile * datFile String, the String, the String * bmpFile); 


This why extern "C"? Way of c + + compiler?


The only emphasis on the function symbol name is C way rather than the way of C + + (C + + name after beating will be like? nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related