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.
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.
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.
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.
Status changed to incomplete because answers are necessary to deal with bug.
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!
And what about preprocessor states? Could you dump them and attach them here?
Sure, how do I do that?
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
Created attachment 154311 [details] Preprocessor dump of lesson01
Created attachment 154312 [details] Preprocessor dump of common/optimize_image.h
Created attachment 154313 [details] Preprocessor dump of common/test.h
I had to recreate test.h but now I hope you have all you need.
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)
> 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).
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.
Thanks, in any way the project will help a lot.
Created attachment 154364 [details] project rar The full project as requested
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.
Ok. I did as you said. I hope this will fix the issue in the future. Thanks again.