07-25-2010 07:19 AM
Hello,
I am confused by the menu options, from the menu of Build>>Configuration, it can specify the X64 option that seems it can generate a 64-bit program, but from the menu of Options>>Build options..., the default call convention not has the option of __fastcall. I am not sure if just specify the Build>>Configuration to X64, that the generating code is a pure 64-bit?
David
07-26-2010 12:38 AM - edited 07-26-2010 12:40 AM
Hi David,
Seems just change build configurations could work. Please check "Creating 64-bit Applications Versus 32-Bit Applications" in CVI help, it says by selecting build configuration could generate a 64-bit application.
Xiaojian Wang
07-26-2010 03:35 AM
Hi, Wang,
But what is the role that the menu of "Options>>Build Options..."?
Another question, As to CVI 2009 help doc, the "Porting 32-bit code to 64-bit code", it shows if programming 64-bit code, e.g., state the integer, it should use the specifier "ssize_t" instead of using "int", but why the call back function still use "int" to state its returns?
David
07-26-2010 10:49 AM
David,
The calling convention setting in the Build Options dialog only applies to 32-bit builds. That's why it has "(32-bit)" in the name. The reason __fastcall isn't shown in the Build Options dialog is because there is nothing to choose -- that is the only calling convention that can be used with 64-bit builds.
As for size_t (and ssize_t), I think you might be misunderstanding that portion of the help topic. You do not have to (nor should you) change all your integers to size_t. As Wolfgang mentioned earlier, you should only change the types of integers which might hold 64-bit values in the 64-bit version of your application. The return value of a callback is not an example of something that would ever hold a 64-bit value, so it was not changed to size_t.
Luis
07-26-2010 06:55 PM
Think you LuisG, as your explanation, I understand somewhat. I also ask another question: if programming a dll code with cvi 2009, should it state explicit the qualifier __fastcall" ?
David
07-27-2010 10:17 AM
Within CVI, it's unnecessary, since __fastcall is already assumed for any functions compiled in 64-bit.
However, since this is a dll, if there's any chance that this dll will be used by programs built with a different compiler, it's probably a good idea to include it. It's always a good idea to state the calling convention explicitly when creating dlls.
If you do include it, make sure to include it both in the function definition (.c file) and in the declaration (.h file).
Luis
07-28-2010 07:09 PM
Hi Luis,
Thank you for the reply. In fact, there are a lot of 32-bit dlls would to be called in the 64-bit applications, due to I can not acquire the source code, means can not recompile them, is there any way to call the 32-bit dll in a 64-bit program?
David
07-29-2010 08:03 AM
As far as I am aware, there is no mechanism in Windows to call a 32-bit DLL from a 64-bit application.
07-29-2010 11:04 AM
That's correct, you cannot load a 32-bit DLL onto a 64-bit process, or vice-versa. If you're stuck with 32-bit DLLs that you cannot recompile, then you will have to create a second process, that can be 32-bit, which will load these DLLs for you. And you'll then have to set up some communication mechanism (TCP, etc...) between the two processes.
Luis
07-30-2010 07:57 AM
Hi Luis,
Thank you for your advise.
David