- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
INTEGER(1) , ALLOCATABLE, TARGET:: Buf(:)
TYPE(T_PRINTER_INFO_2) PI2
POINTER(pPI2, PI2)
....
....
ALLOCATE(Buf(iBytesNeeded), STAT = iErr)
! Buf() will be filled inwith PRINTER_INFO_2 structure
! by win32 fn. GetPrinter()
pPI2 = LOC(Buf)
....
DEALLOCATE(Buf, STAT = iErr)
.....
Questions
1) Pointersand Targets should be the same type, but Buf is type Integer and pPI2points to a Derived Data type, is this a potential problem in theabove code?
2) does Buf() need the Target attribute?
3)would INTEGER(4) for Buf()be better for the Compiler?
(Can always calculatethe correct number of dbl words to Allocate)
4) OR would it be more appropriate, here,to use the intrinsic function MALLOC() to achieve the same results?
Thanks for any information.
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You should use malloc for this - ALLOCATABLE allows the compiler to make some assuimptions that your program might violate. Typically, PI2 would be declared as type T_PRINTER_INFO, or whatever... Try not to "fool" the compiler if you don't have to.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Steve, appreciate the information.

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