Click here to Skip to main content
15,913,722 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionPossible Vista bug? Pin
DougVC18-Feb-08 8:07
DougVC18-Feb-08 8:07 
AnswerRe: Possible Vista bug? Pin
Mark Salsbery18-Feb-08 8:52
Mark Salsbery18-Feb-08 8:52 
GeneralRe: Possible Vista bug? Pin
DougVC18-Feb-08 11:04
DougVC18-Feb-08 11:04 
GeneralRe: Possible Vista bug? Pin
Mark Salsbery18-Feb-08 11:09
Mark Salsbery18-Feb-08 11:09 
GeneralRe: Possible Vista bug? Pin
DougVC19-Feb-08 5:26
DougVC19-Feb-08 5:26 
Generalselection tool for raster images Pin
Blaq18-Feb-08 7:31
Blaq18-Feb-08 7:31 
Generalimport library Pin
George_George18-Feb-08 2:55
George_George18-Feb-08 2:55 
GeneralRe: import library Pin
Randor 18-Feb-08 5:15
professional Randor 18-Feb-08 5:15 
Hello George,

The article in question is referring to functions imported from a DLL. When you call a function which resides in a DLL the linker generates an address pointer which will point to a thunk. A thunk is a function which accesses a table containing address translations. By default the linker will generate a 'call instruction' or JMP instruction to the thunk. This takes additional cpu cycles.

The article describes using __declspec(dllimport) which will instruct the linker that the function resides in an external DLL. Once the linker knows this, it can generate better performing code. Rather than generating a 'call instruction' the linker will generate an indirect call through the IAT entry. Essentially the linker is inlining the thunk.


For Example:

__declspec(dllimport) void Myfunction(void);
int main()
{
	Myfunction();
}


generates an indirect call such as:

ff 15 00 00 00 00 call DWORD PTR __imp__Myfunction

So now the linker has generated optimized code with a single indirect call instruction. In addition to what the article mentions... if all DLL calls from the application are hinted with __declspec(dllimport) this will cause the linker to not generate thunk code which will save 6 bytes plus 1 byte per call site on the final PE image.

Hope this helps,
-Randor (David Delaune)
GeneralRe: import library Pin
George_George18-Feb-08 15:44
George_George18-Feb-08 15:44 
GeneralRe: import library Pin
Mike Dimmick18-Feb-08 7:51
Mike Dimmick18-Feb-08 7:51 
GeneralRe: import library Pin
George_George18-Feb-08 15:42
George_George18-Feb-08 15:42 
QuestionHiding mouse ? Pin
kk.tvm18-Feb-08 2:17
kk.tvm18-Feb-08 2:17 
AnswerRe: Hiding mouse ? Pin
Iain Clarke, Warrior Programmer18-Feb-08 2:41
Iain Clarke, Warrior Programmer18-Feb-08 2:41 
AnswerRe: Hiding mouse ? Pin
Rajkumar R18-Feb-08 2:46
Rajkumar R18-Feb-08 2:46 
GeneralQuestion about connection with FTP server ( What wrong with my code .... ? ) [modified] Pin
Yanshof18-Feb-08 1:33
Yanshof18-Feb-08 1:33 
GeneralRe: Question about connection with FTP server ( What wrong with my code .... ? ) Pin
Rajkumar R18-Feb-08 1:54
Rajkumar R18-Feb-08 1:54 
GeneralRe: Question about connection with FTP server ( What wrong with my code .... ? ) Pin
Yanshof18-Feb-08 2:08
Yanshof18-Feb-08 2:08 
GeneralRe: Question about connection with FTP server ( What wrong with my code .... ? ) Pin
David Crow18-Feb-08 2:54
David Crow18-Feb-08 2:54 
GeneralRe: Question about connection with FTP server ( What wrong with my code .... ? ) Pin
Yanshof18-Feb-08 3:06
Yanshof18-Feb-08 3:06 
QuestionRe: Question about connection with FTP server ( What wrong with my code .... ? ) Pin
David Crow18-Feb-08 3:15
David Crow18-Feb-08 3:15 
GeneralRe: Question about connection with FTP server ( What wrong with my code .... ? ) [modified] Pin
Yanshof18-Feb-08 3:21
Yanshof18-Feb-08 3:21 
GeneralRe: Question about connection with FTP server ( What wrong with my code .... ? ) Pin
David Crow18-Feb-08 4:43
David Crow18-Feb-08 4:43 
GeneralRe: Question about connection with FTP server ( What wrong with my code .... ? ) Pin
Yanshof18-Feb-08 4:57
Yanshof18-Feb-08 4:57 
QuestionHow can I check the exsistence of a Registry Key? Pin
J_E_D_I18-Feb-08 1:21
J_E_D_I18-Feb-08 1:21 
AnswerRe: How can I check the exsistence of a Registry Key? Pin
Rajkumar R18-Feb-08 1:26
Rajkumar R18-Feb-08 1:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.