If this is a DLL and you are compiling with MSVC / Visual C++, you can explicitly align the struct members:
struct g_thread_param {
int thr_cnt ;
int indv_cnt ;
__declspec(align(4096)) char mem_buff[XX];
} ;
質問
My need is to aligned the memory by 4096, since this is the requirement of the dll I am using. so previously it was no problem since just I used to have
char *mem_buff = (char *)_aligned_malloc(sizeof(char)*XX, 4096);
but now since I want to share the memory using struct (for the reason of using the threads) hence I am stuck with what and how to do?
struct g_thread_param {
int thr_cnt ;
int indv_cnt ;
char mem_buff[XX]; //what to do to aligne this to 4096
} ;
thanks
解決
If this is a DLL and you are compiling with MSVC / Visual C++, you can explicitly align the struct members:
struct g_thread_param {
int thr_cnt ;
int indv_cnt ;
__declspec(align(4096)) char mem_buff[XX];
} ;