- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear all,
I have a mixed Fortran/C++ project by MSVC2010 + IVF2011 on Windows 7 64 bit system. I need to delete and reallocate the pointer array defined in Fortran code. However, the code will crash when delete the pointer array in C++.
The code is as follows:
Fortran:
type outputobj0
integer::intarraysize=0
integer::doublearraysize=0
integer,pointer::intarray(:)=>null()
real*8,pointer::doublearray(:)=>null()
end type
type(outputobj0)::out
call F_call_C(c_loc(out))
C++:
typedef struct outputobj0
{
int intarraysize;
int doublearraysize;
int *intarray;
double *doublearray;
}outputobj;
void F_call_C(outputobj *out)
{
...
if(out->intarray)delete [] out->intarray;
if(out->doublearray)delete [] out->doublearray;
out->intarray = new int [out->intarraysize];
out->doublearray= new int [out->doublearray];
}
The code will crash at this line:
if(out->intarray)delete [] out->intarray;
I want to know whether it is possible to delete the point array declared in Fortran and renew it? How to modify the code to let it work?
Thanks,
Zhanghong Tang
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

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