- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Should you declare theelemental intrinsic function malloc in a program? Is the declaration in this example appropriate for the 64 bit compiler? I am using a program that declares malloc as an integer that is compiled 64 bit and is working fine. Is the declaration correct, ignored, or have I just been lucky? I believe p1 and p1 are correct just not sure how to handle the declaration (if it is needed or required) of malloc.
[cpp] program mem implicit none integer malloc,i <==== malloc declaration pointer (p1, fred) pointer (p2, jack) integer size real fred(*),jack(*) print *,'How big?' read *,size p1 = malloc(4*size) p2 = malloc(4*size) do i=1,(size) fred(i)=i jack(i)=i end do print *,jack(size),fred(size) end [/cpp]
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You should not declare malloc, but if you want to, do it this way:
integer(int_ptr_kind()) malloc
Your declaration is ignored if it is an intrinsic.
This will be correct on both 32 and 64-bit systems.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page