- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I hit an issue with the debugger - it gets confused about the line the source is in:
I know this happens when your build/pdb is out of date, this is not the case here. Instead it is related to a somewhat weird combination of #include (preprocessor) and include (Fortran).
To reproduce I have 4 files: 2 include files, one module and a main:
SomeFile.fi:
integer, parameter :: someval = 88
OtherFile.fi:
!#DEFINE BLA_BLA
#IF .NOT. DEFINED (BLA_BLA)
#DEFINE MyFun(a, b, c) .true.
#ELSE
USE, INTRINSIC :: ISO_C_BINDING, ONLY: C_LOC
#ENDIF
TestInclude.f90 (do not remove the empty line 14 for clarity):
module MTestInclude
#include "OtherFile.fi"
#IF DEFINED (SIGNAL_MEM_ARRS)
use NonExistantModule
#ENDIF
implicit none
save
contains
subroutine test()
include "SomeFile.fi"
write(*,*) someval
end subroutine test
end module MTestInclude
Console1.f90:
program main
use MTestInclude
call test()
end program main
It does not only offset the debugger in the function with the include, but also for other functions defined after that one in the same file. Interestingly it seems you need the combination of #include and include to break it.
So for me the simple workaround is to include "OtherFile.fi" instead of #include "OtherFile.fi", just thought it might be of interest. Or maybe there is something actually wrong with the #include version?
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
FWIW I use fpp and #include extensively in my solution, but I do not use "include". I do not have a line positioning error.
Note, if you are compiling with any optimizations enabled, you can(may) see such behavior.
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Jim. This is in a Debug build with no optimizations. But good point about only using #include: Another way to get it to work as it should.

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