小编Abd*_*yaf的帖子

在Linux上,打印功能地址总是打印1(c ++)

我正在开发一个处理不同变量和函数地址的c ++程序.

当我在基于Linux的操作系统上编译我的程序时,包括main的所有函数都获得1的地址而不是像其他变量一样的8位六进制数,这在Windows中没有发生.

我写了这段小代码来解释这个问题

#include <iostream>
using namespace std;
void Function1();
void Function1()
{
}
int main()
{
int tmp;
void (*a) ()=&Function1;
cout<<a<<endl;
cout<<&Function1<<endl;
cout<<&main<<endl;
return 0;
}
Run Code Online (Sandbox Code Playgroud)

对于所有3个cout呼叫,输出为1而不是虚拟地址.

我真的很感谢你的帮助

感谢Advance Aziz

c++ printing cout virtual-memory

1
推荐指数
1
解决办法
143
查看次数

标签 统计

c++ ×1

cout ×1

printing ×1

virtual-memory ×1