<div>Hello,</div>
<div> </div>
<div>How I can allocate a chunk of memory in a named address space different than #0 (or intrinsic)?</div>
<div> </div>
<div>I tried...</div>
<div> </div>
<div>#define HEAP_2 __attribute__((address_space(2)))</div>
<div>#include <stdlib.h></div>
<div>int main() {</div>
<div> int HEAP_2 *ptr = malloc(10 * sizeof (int));<br> if (ptr == NULL) {<br> }<br> else {<br> free(ptr);<br> ptr = NULL;<br> }<br> return (1);<br>}<br>
</div>
<div> </div>
<div>However, I got...</div>
<div> </div>
<div>++++++++++++++++++++++++++++++++++++++++++++++</div>
<div><a href="mailto:8@emperor:~/test$">~/test$</a> clang malloc_pift.c <br>malloc_pift.c:7:20: error: illegal implicit cast between two pointers with different address spaces<br> int HEAP_2 *ptr = malloc(10 * sizeof (int));<br>
^~~~~~~~~~~~~~~~~~~~~~~~~<br>malloc_pift.c:7:20: warning: initializing 'void *' discards qualifiers, expected 'int __attribute__((address_space(2))) *'<br> int HEAP_2 *ptr = malloc(10 * sizeof (int));<br>
^~~~~~~~~~~~~~~~~~~~~~~~~<br>malloc_pift.c:8:13: error: illegal implicit cast between two pointers with different address spaces<br> if (ptr == NULL) {<br> ^~~~<br>/home/jcmartin78/llvm/Debug/lib/clang/1.1/include/stddef.h:38:14: note: instantiated from:<br>
#define NULL ((void*)0)<br> ^~~~~~~~~~<br>malloc_pift.c:11:12: error: illegal implicit cast between two pointers with different address spaces<br> free(ptr); <br> ^~~<br>malloc_pift.c:11:12: warning: passing 'int __attribute__((address_space(2))) *' discards qualifiers, expected 'void *'<br>
free(ptr); <br> ^~~<br>malloc_pift.c:12:13: error: illegal implicit cast between two pointers with different address spaces<br> ptr = NULL;<br> ^~~~<br>
/home/jcmartin78/llvm/Debug/lib/clang/1.1/include/stddef.h:38:14: note: instantiated from:<br>#define NULL ((void*)0)<br> ^~~~~~~~~~<br>6 diagnostics generated.</div>
<div>++++++++++++++++++++++++++++++++++++++++++++++=<br clear="all"></div>
<div></div>
<div>Thanks in advance,</div>
<div><br>-- <br>Juan Carlos<br></div>