"Jump to" not working for code appearing inside #ifdef's

43 views
Skip to first unread message

mark1977

unread,
Feb 8, 2022, 9:33:31 PM2/8/22
to CBFortran
Hi,

I have parts of my code that are between #ifdef.....some code....#endif, and I compile with -fpp.
When I right click and choose "Jump to" for any routine that appears inside these statements, codeblocks is unable to find them.
My version is info is below.

Thanks!

------------------------------------------------------------------------------------------------
Name             : Code::Blocks
Version          : svn-r12045
SDK Version      : 2.2.0
Scintilla Version: 3.7.5
Author           : The Code::Blocks Team
E-mail           : in...@codeblocks.org
Website          : http://www.codeblocks.org

wxWidgets Library (wxMSW port)
Version 3.1.4 (Unicode: wchar_t, debug level: 1),
compiled at Apr  3 2020 09:35:29

Runtime version of toolkit used is 10.0.

Darius Markauskas

unread,
Feb 9, 2022, 2:35:07 AM2/9/22
to cbfo...@googlegroups.com
 Hello Mark

In my tested case, 'Jump to' works.
Perhaps you could disable "Interpret preprocessor directives" (see screenshot below) and see if "Jump to" now works. To be sure, close and reopen your project after changing these settings.

Could you, please, prepare a short test case which causes this problem?


CB_settings_screenshot.png


--
You received this message because you are subscribed to the Google Groups "CBFortran" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cbfortran+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cbfortran/41e7ab5b-ac95-4312-b9cc-d74cf7185e90n%40googlegroups.com.

mark1977

unread,
Feb 10, 2022, 2:19:55 AM2/10/22
to CBFortran
Hi Darius,
Thanks for your reply. I do not have the "Interpret preprocessor directives" option available inside Configure Editor->Fortran Project, maybe my version is too old?
If not, I'll make a short test case as you suggest.

Darius Markauskas

unread,
Feb 10, 2022, 3:13:39 AM2/10/22
to cbfo...@googlegroups.com
 I thought you have latest C::B from cbfortran.sourceforge.io. If you have a bit older version, then it could be the opposite situation: C::B doesn't interpret preprocessor directives and therefore your code is parsed wrongly. Check on FSymbols browser if you find there names of procedures where you want to 'Jump to'.
The latest version of C::B tries to interpret pre-processor directives. However C::B does not always succeed. Preprocessor directives are tricky...


mark1977

unread,
Feb 10, 2022, 4:06:29 PM2/10/22
to CBFortran
Under FSymbols browser, I don't see any names of procedures.
So, I updated to the latest version (1.8) and tried again. Same issue, regardless of whether "interpret preprocessor directives" is checked or not.
Here is the simplest code that reproduces the bug (compile with -fpp and -Dsomething):

!-------------------------------------------------------------------------
program exmaple1

call test

end

#ifdef something

subroutine test
print*,'success'
end

#endif
!------------------------------------------------------------------------------

Darius Markauskas

unread,
Feb 11, 2022, 6:36:27 AM2/11/22
to cbfo...@googlegroups.com
I just hope you are patient enough ;)

In your test case, C::B with "interpret preprocessor directives" disabled will function correctly. However, with "interpret preprocessor directives" enabled not, because C::B doesn't know anything about the "something" constant you defined on your command line. You should see the subroutine "test" shadowed on the editor. You can tell C::B (Fortran project plugin) about the defined constant on the Project->Properties dialog (see a screenshot).

CB_Project_properties_screenshot.png

mark1977

unread,
Feb 11, 2022, 8:52:57 PM2/11/22
to CBFortran
Hi Darius,

Thanks again for your reply. I confirm that in my test case, if I have "interpret preprocessor directives" disabled, it still does not function correctly. i.e. it still does not find the function when right clicking and choosing "Jump to". I attached 2 screenshots below. My current version is svn-r12309.

darius1.pngdarius2.png

Darius Markauskas

unread,
Feb 13, 2022, 4:18:53 AM2/13/22
to cbfo...@googlegroups.com
Thank you Mark. Now I see the problem in C::B. It is some bug in the FP plugin. I hope I can find and fix it soon.

Darius

Darius Markauskas

unread,
Feb 13, 2022, 1:51:39 PM2/13/22
to cbfo...@googlegroups.com
One more question: does C::B work as you expect when "interpret preprocessor directives" is enabled?

mark1977

unread,
Feb 13, 2022, 7:46:25 PM2/13/22
to CBFortran
No CB doesn't work as expected either way - i.e. it doesn't find the routine even when "interpret preprocessor directives" is enabled.

Darius Markauskas

unread,
Feb 14, 2022, 4:11:43 AM2/14/22
to cbfo...@googlegroups.com
"""No CB doesn't work as expected either way - i.e. it doesn't find the routine even when "interpret preprocessor directives" is enabled."""

Sorry, but I can't repeat it. On my system, C::B finds and jumps to "test" subroutine if "interpret preprocessor directives" is enabled AND
"something" is defined in the project properties dialog.
Perhaps you forgot to add "something" in Project->Properties dialog? (I am adding the screenshot again).




CB_Project_properties_screenshot.png

mark1977

unread,
Feb 15, 2022, 4:23:01 PM2/15/22
to CBFortran
Sorry you are right I did forget to add "something" to the project properties. Now it works as expected.

Darius Markauskas

unread,
Feb 19, 2022, 1:58:51 PM2/19/22
to cbfo...@googlegroups.com
About the reported problem when the "Interpret preprocessor directives" option is disabled:
I have just committed required changes (very small) to the code of FortranProject plugin Rev.333.

Thank you Mark for reporting this issue.


mark1977

unread,
Feb 20, 2022, 7:54:58 PM2/20/22
to CBFortran
Thank you Darius, I'll try the new Rev.
Reply all
Reply to author
Forward
0 new messages