This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 252698 - Code assistance failing files in sub folders
Summary: Code assistance failing files in sub folders
Status: RESOLVED INCOMPLETE
Alias: None
Product: cnd
Classification: Unclassified
Component: Code Model (show other bugs)
Version: 8.0.2
Hardware: PC Windows 7
: P2 normal (vote)
Assignee: petrk
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-05-30 12:27 UTC by antoniocs
Modified: 2015-07-02 07:59 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Display error of include file problem (73.20 KB, image/png)
2015-05-30 12:27 UTC, antoniocs
Details
Preprocessor dump of lesson01 (37.94 KB, text/plain)
2015-06-20 18:07 UTC, antoniocs
Details
Preprocessor dump of common/optimize_image.h (204.76 KB, text/plain)
2015-06-20 18:09 UTC, antoniocs
Details
Preprocessor dump of common/test.h (39.85 KB, text/plain)
2015-06-20 18:11 UTC, antoniocs
Details
project rar (2.68 MB, application/x-rar-compressed)
2015-06-23 20:12 UTC, antoniocs
Details

Note You need to log in before you can comment on or make changes to this bug.
Description antoniocs 2015-05-30 12:27:55 UTC
Created attachment 153967 [details]
Display error of include file problem

I am trying to do some work with SDL (following LazyFoo SDL2 tutorials). 
I have it configured in my machine and I get no errors when I compile.

The problem occurs when I create files in nested folders.
In my root folder I have the following structure

+---lessons
|   |   lesson01.c
|   |   lesson02.c
|   |   lesson03.c
|   |   lesson04.c
|   |   lesson05.c
|   |
|   \---common
|           close.c
|           close.h
|           init.c
|           init.h
|           loadmedia.c
|           loadmedia.h
|           optimize_image.c
|           optimize_image.h

If I include the header file SDL.h in any of lesson files I have no issues, but when I include it in the files in the common folder I get the following warning:

"Cannot find include file <SDL.h>."

I have tried a few times going to Code Assistance > Reparse Project but that doesn't do anything.

One thins that works some times seems to be closing the file and then opening it up again. Now this is simple but I spent quite some time going through my configs making sure everything was ok and this only works sometimes.

I have attached a screenshot so that you can view the problem.
You will see 3 files opened. 
Two from the common folder and one which is in the parent folder. Only the test.h (which I created just before taking the screenshot) has the warning (and it wasn't fixed when I closed and opened, but that trick worked on the optimize_image.h file).

Still a great editor just needs a tweak here and there.
Comment 1 petrk 2015-06-10 14:43:49 UTC
As far as I understand you rely on NetBeans when it comes to project management. I mean that you have created this project in NetBeans and it maintains Makefiles for you. In this case, please, note that configuration (inculde dirs, preprocessor definitions, etc) is organized hierarchically and here could be the problem. 

Sometimes that behavior is not a bug: imagine that you've created a file "aaa.cpp", then you set additional include directories for it (right click on file->Properties->C++ Compiler) and included file "library.h" into it. Everything is ok for now and "library.h" should be resolved. After that you create file "test.h" and include "library.h" into it as well. Here library.h will be unresolved because "test.h" is a header file and it is not included into any translation unit, so it doesn't have any configuration yet. At the same time the whole program will be compilable because header files are not entry points of translation units, i.e. compiler doesn't compile "test.h"! You cannot configure standalone header file, so the solution is either to include from some file, or to set additional include directories for the whole project (or folder).

To deal with your issue we have to know that the project configured properly. Please, have a look at configurations for the whole project, for the folders (common, lessons) and for the concrete files. If you configured only the whole project and all other configurations are set to "Inherited" then it is a bug. Otherwise it may be expected behavior.
Comment 2 petrk 2015-06-10 14:50:08 UTC
Also it is worth to attach here dumps of preprocessor states for three files: 
1) lesson01.c
2) optimize_image.h
3) test.h

To dump preprocessor states open for the file open it in the editor, then right click on the project->Code Assistance->Dump C/C++ Code Model Diagnostics, check "Preprocessor States" checkbox and press OK.
Comment 3 petrk 2015-06-15 12:10:58 UTC
Status changed to incomplete because answers are necessary to deal with bug.
Comment 4 antoniocs 2015-06-17 07:54:01 UTC
Sorry for not saying anything.
I have checked the folders and they seem to inherit from the main configuration.

The only place where I see this set explicitly is in the "C Standard".

I assume such configuration would be by default. Why would I set specific configs for folders. I think this is a bug!
Comment 5 petrk 2015-06-17 11:18:48 UTC
And what about preprocessor states? Could you dump them and attach them here?
Comment 6 antoniocs 2015-06-19 07:02:00 UTC
Sure, how do I do that?
Comment 7 petrk 2015-06-19 11:06:16 UTC
Open a file in editor, then right click on the project->Code Assistance->Dump C/C++ Code Model Diagnostics, check "Preprocessor States" checkbox and press OK. The dump will appear in output window. Please do it for the next files: 
1) lesson01.c
2) optimize_image.h
3) test.h
Comment 8 antoniocs 2015-06-20 18:07:44 UTC
Created attachment 154311 [details]
Preprocessor dump of lesson01
Comment 9 antoniocs 2015-06-20 18:09:30 UTC
Created attachment 154312 [details]
Preprocessor dump of common/optimize_image.h
Comment 10 antoniocs 2015-06-20 18:11:58 UTC
Created attachment 154313 [details]
Preprocessor dump of common/test.h
Comment 11 antoniocs 2015-06-20 18:12:28 UTC
I had to recreate test.h but now I hope you have all you need.
Comment 12 antoniocs 2015-06-20 18:14:15 UTC
One thing I did notice right now is that the SDL directories are not there.
This file is created in the same dir as optimize_image.h and if that has no issues with SDL.h I assume this shouldn't have a problem either, meaning that the directory should be in this debug file (but is not)
Comment 13 petrk 2015-06-23 14:27:21 UTC
> One thing I did notice right now is that the SDL directories are not there.
Do you mean that SDL is not installed? I suppose not because other files do not have any issues with sdl, so they are able to locate SDL.h. 

The thing is that preprocessor states for "test.h" do not contain path to SDL in "User include directories" section. Usually this is an indicator of incorrect configuration. Can you attach the whole project here? If you do not want me to see your code, you can delete it completely (leave only include directives, because they matter here).
Comment 14 antoniocs 2015-06-23 14:37:46 UTC
No no. What I meat is that the SDL directories are not in the dump of test.h but they are in optimize_image.h and they are in my machine.

I have no issue with you seeing the code as it is on github. 
As soon as I get home I will post the whole project, but I suspect this is actually an issue in Netbeans. optimize_image.h is in the same folder as test.h so it should have all the directories that optimize_image.h has.
Comment 15 petrk 2015-06-23 14:43:27 UTC
Thanks, in any way the project will help a lot.
Comment 16 antoniocs 2015-06-23 20:12:47 UTC
Created attachment 154364 [details]
project rar

The full project as requested
Comment 17 petrk 2015-06-24 11:59:10 UTC
Well, first of all, I suppose there is a mistake at Project properties->Code Assistance->C Compiler. You should transfer everything from "Include Headers" to "Include Directories" because I doubt that "C:/SDL2/SDL2-2.0.3/i686-w64-mingw32/include/SDL2" is a file. It must be a directory, right?

Second of all, copy those paths to "Project properties->Code Assistance->C++ Compiler->Include Directories" because when you create an orphan header the default preprocessor state (include dirs, files, predefined macroses) will be fetched from C++ Compiler options. (In fact it is impossible to say how the header file will be compiled unless it is included from somewhere, so just remember the default behavior is to use C++ options).

Hope that helps.
Comment 18 antoniocs 2015-07-02 07:59:38 UTC
Ok. I did as you said. I hope this will fix the issue in the future.

Thanks again.