the*_*ejh 3 c++ gcc coding-style
出于运行速度原因,使用#include "randombytes.cpp"而不是randombytes.h在我的项目中(randombytes.cpp我的项目源代码目录中的文件)是一个好主意吗?看起来像这样:randombytes.cpp
#ifndef RANDOMBYTES_INCLUDED
#define RANDOMBYTES_INCLUDED
/* include native headers here */
unsigned char *fetch_random_bytes(int amount);
/* include other parts of my project here if necessary */
unsigned char *fetch_random_bytes(int amount) {
// do stuff
}
#endif
Run Code Online (Sandbox Code Playgroud)
这对于需要彼此等的文件也适用,对吧?你能想到任何不起作用的情况,或者我不会得到优化的好处吗?
这种做法被称为"Unity Build"(google it),除了琐碎的项目之外通常不是一个好主意,因为每次进行一次更改都需要重新编译整个项目,这可能意味着每次你都要等待几分钟修复一个小错误.
至于运行时性能,速度差异与使用链接时间优化进行编译没有太大差别.
| 归档时间: |
|
| 查看次数: |
166 次 |
| 最近记录: |