# shared memory alignment

**URL:** <https://forums.developer.nvidia.com/t/shared-memory-alignment/16628>\
**Category:** CUDA Programming and Performance\
**Created:** [May 14, 2010, 8:09pm UTC](https://forums.developer.nvidia.com/t/shared-memory-alignment/16628 "2010-05-14T20:09:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![gzaki](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@gzaki](https://forums.developer.nvidia.com/u/gzaki)\
**Post date:** [May 14, 2010, 8:09pm UTC](https://forums.developer.nvidia.com/t/shared-memory-alignment/16628/1 "2010-05-14T20:09:57Z")

</div>

Dear All,

I am dynamically allocating shared memory as shown in the code. From the programming guide, arrays has to be aligned. I tried this code but get the following error:

error: expression must have integral or enum type

[codebox]#define ALIGN(ADDRESS, OFFSET) (((ADDRESS) + (OFFSET) - 1) & (~((OFFSET) - 1)))

extern **shared** char array;

**global** void decoderKernel( …) {

char _syndrome\_buffer = (char_) ALIGN(array, sizeof(char));

float _soft\_output = (float_) ALIGN(&syndrome\_buffer[n], sizeof(float));

}[/codebox]

Thanks.

---

<div class="post-metadata">

**Author:** ![tan2](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@tan2](https://forums.developer.nvidia.com/u/tan2)\
**Post date:** [May 17, 2010, 5:27pm UTC](https://forums.developer.nvidia.com/t/shared-memory-alignment/16628/2 "2010-05-17T17:27:17Z")

</div>

> [@](#):
>
> extern **shared** char array;

Shared memory must reside within the kernel.
