【发布时间】:2012-07-23 15:22:27
【问题描述】:
编辑:这是我的一个工作项目。在职的。 我在 .cpp 文件的开头声明了一些 char 数组(甚至在 #include 部分之前)。然后我可以将这些数组与“16 字节对齐变量的指令”一起使用。
问题:如果我在另一个 .cpp 文件中使用这个 .cpp 文件作为包含会发生什么?我也可以在其他项目中使用该数组进行对齐操作吗?
问题 2:有捷径吗?我不想把我所有的变量都放在开头。
一些代码:(我处理了一些 16 字节对齐的数组)
//I put these arrays at the beginning, so they are aligned
//for the movaps instructions(x2 speed for reading and writing memory)
float v1[16];
float v2[16];
char counters[32];
char array_of_ones[32];
char source_array[4096];
char destination_array[4096];
struct bit_field
{
bf1:32;
bf2:32;
bf3:32;
bf4:32;
}some_area;
struct bit_mask_x
{
bf1:32;
bf2:32;
bf3:32;
bf4:32;
}some_mask;
float var_fast[16];
char alignment_purge[5]; //for the unalignment tests
char unaligned_source_array[4096];
char unaligned_destination_array[4096];
#include <math.h>
#include<stdlib.h>
#include<stdio.h>
#include<time.h>
.....
.....
如果我将这个程序包含在另一个这样的程序中会发生什么:
#include <math.h>
#include<my_aligned.h> <-------- or my_aligned.cpp
#include<stdio.h>
#include<time.h>
我必须为此使用 .h 文件吗?
谢谢...
【问题讨论】:
-
#include <iostream.h>为什么要使用 pre-ansi 标头? -
我正在从旧书中学习。我可以更改 iostream.h 吗?
-
@tuğrulbüyükışık 如果你买不起最近的教科书,你最好使用一些免费的在线文本而不是过时的东西。
-
好的,我删除了那个流。我现在能做什么?
标签: c++ arrays alignment memory-alignment