小编lon*_*ppl的帖子

在 G++ 中使用 -frepo 选项

我的工作地点是为一些没有虚拟内存的绝对古老的硬件开发代码。正因为如此,我们会尽量减少对象和二进制文件的文本大小,以免内存不足。这可能意味着我们需要限制使用来自 STL 的模板,或者完全禁止它们。在环顾四周寻找最小化文件大小并仍然使用模板的方法时,我遇到了-frepog++的选项。几次测试后,我比开始时更加困惑。使用 -frepo 时,最终的二进制文件大小相同或更大,这对我来说没有意义。任何人都可以向我解释这个选项实际上做了什么(除了“它只是有效”,因为这是 GCC 4.7.1 手册中的解释)以及我可能如何滥用它?

编译g++ -c -frepo main.cpp test8.cpp和链接 正在g++ test8.o main.o 创建 .rpo 文件。

测试8.h:

#include <list>
using namespace std;

class Test
{
  public:
    Test ();
    list<int> makeNewIntList ();
  private:
  list<int> intList;
};
Run Code Online (Sandbox Code Playgroud)

测试8.cpp:

#include "test8.h"
#include <list>

using namespace std;

Test::Test()
{
  intList = list<int>( 10, 12 );
}

list<int> Test::makeNewIntList()
{
  intList.push_back(4);
  return intList;
}
Run Code Online (Sandbox Code Playgroud)

主程序

#include "test8.h"

using namespace std;

void findFive (int num);
list<int> makeIntList();

int …
Run Code Online (Sandbox Code Playgroud)

c++ templates g++

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

标签 统计

c++ ×1

g++ ×1

templates ×1