C++/register int and VC++ DLL
I have few questions on C and VC++.
(1) What is the difference between datatype "int" and "register int"?
Is "int" by default set to "register"? Since "register int"
increases the speed of loops, can I use them at all times, or there
(2) I created a VC++ DLL (Win32 simple DLL), and I want to call its
functions from my MFC project. I tried __declspec, but not getting it
right still. Can you illustrate the steps comprehensively. I even read
articles on some site, but still not getting. How to use LoadLibrary(),either?
Rohit , Thank you for your question.
1. "register" is one of the keywords used to give a hint to the compiler as to how to generate code. In this case, you are asking the compiler to try to keep a variable in a register instead of in memory. Registers can be accessed much faster than memory locations. A compiler is free to ignore hints like "register". The limitation is that most CPUs have very few registers free for use by the program. If you mark ten variables as "register", it is possible that none of them will actually be assigned to a register. Probably one or two concurrent "register" variables will work on some host systems. It all depends. It is probably better to write speed-critical software in assembly language for the specific host CPU; then you have full control over variable allocation and program execution.
2. I regret that I am unable to write a guide for DLL programming because of the volume of questions received. If you have any specific questions, please do not hesitate to ask!