 |
forums.silverfrost.com Welcome to the Silverfrost forums
|
| View previous topic :: View next topic |
| Author |
Message |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8283 Location: Salford, UK
|
Posted: Thu Nov 15, 2012 7:59 pm Post subject: |
|
|
I am not sure how far to go with you on this. At some point it would be advisable for you to read the manual.
However, having switched off /undef, you can switch on /debug to allow debugging. |
|
| Back to top |
|
 |
davidb
Joined: 17 Jul 2009 Posts: 560 Location: UK
|
Posted: Thu Nov 15, 2012 10:25 pm Post subject: Re: |
|
|
Can you try copying the value like this:
| Code: |
i1Value1L = transfer(pstTileDataP%pstData(iByteOffsetL + 1), i1Value1L)
|
This copies the bits but won't be seen as an assignment so the undefined patten shouldn't be detected.
Transfer is a standard intrinsic function. The second argument is used as a MASK to get the size in bits of the destination and doesn't need to be defined. It can be any integer*1 variable or integer*1 constant, including the destination variable. The first argument should be defined, which it is in your case, since -128 is a valid 1 byte integer.
For example, this code works for me with /UNDEF on or not.
| Code: |
program anon
integer*1 :: aaa
! aaa is not defined
call mmm(aaa)
end
subroutine mmm(ccc)
integer*1 :: ccc, bbb
bbb = transfer(ccc, bbb)
print *, bbb ! should print -128 when /UNDEF on and a junk value when /UNDEF off
end
|
Incidentally, I am finding that /UNDEF only seems to detect 1 byte undefined integers when compiling for .NET. No errors are detected when I compile for Win32.
PS. Transfer has many cool uses, like getting the size of a data type in bytes, size(transfer(data_type, (/'A'/))), and also you can use it as a VOID pointer, ala C, C++ to do generic programming. _________________ Programmer in: Fortran 77/95/2003/2008, C, C++ (& OpenMP), java, Python, Perl |
|
| Back to top |
|
 |
JohnCampbell
Joined: 16 Feb 2006 Posts: 2625 Location: Sydney
|
Posted: Fri Nov 16, 2012 6:11 am Post subject: |
|
|
For this and the previous topic, I would recommend that you review the compiler options you are selecting. I compile my program, using a batch file, selecting different levels of checking for different routines(files) as an FTN95 argument.
The only compiler option I put in my code is WINAPP. I set all debugging compiler options in the batch files.
You can do a lot of checking, without resorting to /undef, such as /check.
If you are going to release an application you should also be aware of the amount of information included in the .exe if you use /check. You might not want to release all this information.
/debug is a very useful level of compile checking, as it is sufficient for maping the code in SDBG and providing an easily readable callback list, without the overhead of address checking or other tests. If the user finds a problem while the program is runing, they can give an informative report of where it occurs. If the problem occurs in the OS, outside the fortran code, then no checking options in the fortran code are likely to help identify that error source.
If you want to solve the problem, there are alternative approaches to the one you have been using.
John |
|
| Back to top |
|
 |
DanRRight
Joined: 10 Mar 2008 Posts: 2945 Location: South Pole, Antarctica
|
Posted: Sun Nov 18, 2012 6:42 am Post subject: |
|
|
I never include winapp. It scares people. LOL I use /win at compile time
What it is for? Isn't it included automatically by the compiler because all works fine without it?
Last edited by DanRRight on Tue Nov 20, 2012 2:09 pm; edited 1 time in total |
|
| Back to top |
|
 |
MarzAttax
Joined: 15 Jun 2006 Posts: 46
|
Posted: Mon Nov 19, 2012 3:57 am Post subject: |
|
|
@DanRRight, @JohnCampbell and @davidb and @others.
Thank you all for your wonderful feedback, I'm going to have a good think about my Development "Style" and perhaps incorporate some of these ideas.
Thanks again.
Marz |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|