假设我在源文件中有这个小功能
static void foo() {}
Run Code Online (Sandbox Code Playgroud)
我构建了二进制文件的优化版本,但我不希望这个函数内联(出于优化目的).我可以在源代码中添加一个宏来阻止内联吗?
我用c ++写了一个简单的程序:
#include <stdio.h>
const signed char pass[] = "\x70\x61\x73\x73\x77\x6F\x72\x64";
bool __stdcall check_password(const signed char * str)
{
unsigned int i;
for(i=0;i<8;++i)
if(str[i]!=pass[i])
return false;
return true;
}
int main(int argc, char * argv[])
{
signed char buf[20];
printf("please enter the password: ");
scanf("%s",buf);
printf((check_password(buf)) ? "correct!\n" : "incorrect.\nPress any key to exit..\n");
getchar();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
并使用visual studio express 2010编译它.
我在OllyDbg中打开了结果,这就是我所看到的:
Address Hex dump Command Comments
00FF1011 ³. 8B35 A020FF00 MOV ESI,DWORD PTR DS:[<&MSVCR100.printf>]
00FF1017 ³. 68 0021FF00 PUSH …Run Code Online (Sandbox Code Playgroud) c ×2
assembly ×1
c++ ×1
c++-faq ×1
declaration ×1
definition ×1
gcc ×1
inline ×1
ollydbg ×1
terminology ×1