Обсуждение: Development with Eclipse - Wrong error messages in IDE
Good morning hackers, I have some strange error message inside Eclipse, that some symbols cannot be found. I work with version 9.6 currently. For instance, Symbol 'RM_HEAP_ID' could not be resolved src/backend/access/heap/heapam.c It affects all occurrences of symbols that are defined in src/include/access/rmgrlist.h. Eclipse just says "Syntax error" here. However, the source code compiles and runs without any compile-time error or warning. It is just an IDE problem I think, but it distracts me from finding real bugs. Does anyone had similar problems? Do I have to configure Eclipse to understand the PG_RMGR macro or is there another possibility to teach Eclipse these macros? Thanks for any help or comment. Best regards, Peter
Peter Moser wrote: > I have some strange error message inside Eclipse, that some symbols cannot > be found. I work with version 9.6 currently. For instance, > > Symbol 'RM_HEAP_ID' could not be resolved > src/backend/access/heap/heapam.c > > It affects all occurrences of symbols that are defined in > src/include/access/rmgrlist.h. Eclipse just says "Syntax error" here. > > However, the source code compiles and runs without any compile-time error or > warning. It is just an IDE problem I think, but it distracts me from finding > real bugs. Disclaimer: I've never used eclipse. The problem is some perhaps-too-clever stuff we do to avoid repetitive declarations of things. The rmgr stuff uses a PG_RMGR macro, which is defined differently in src/backend/access/transam/rmgr.c and src/include/access/rmgr.h; the latter contains the actual enum definition. On the other hand Eclipse is trying to be too clever by processing the C files, but not actually getting it completely right (which is understandable, really). We have other similar cases, such as grammar keywords (kwlist.h) I'm afraid that you'd have to teach Eclipse to deal with such things (which might be tricky) or live with it. -- Álvaro Herrera http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
> Peter Moser wrote: > >> I have some strange error message inside Eclipse, that some symbols cannot >> be found. I work with version 9.6 currently. For instance, >> >> Symbol 'RM_HEAP_ID' could not be resolved >> src/backend/access/heap/heapam.c >> >> It affects all occurrences of symbols that are defined in >> src/include/access/rmgrlist.h. Eclipse just says "Syntax error" here. >> >> However, the source code compiles and runs without any compile-time error or >> warning. It is just an IDE problem I think, but it distracts me from finding >> real bugs. > > Disclaimer: I've never used eclipse. > > The problem is some perhaps-too-clever stuff we do to avoid repetitive > declarations of things. The rmgr stuff uses a PG_RMGR macro, which is > defined differently in src/backend/access/transam/rmgr.c and > src/include/access/rmgr.h; the latter contains the actual enum > definition. On the other hand Eclipse is trying to be too clever by > processing the C files, but not actually getting it completely right > (which is understandable, really). We have other similar cases, such as > grammar keywords (kwlist.h) > > I'm afraid that you'd have to teach Eclipse to deal with such things > (which might be tricky) or live with it. > Ok, thank you for the comment. I think, I can live with it. Perhaps, when I have some spare time I give it a try to solve this "non-issue"... Cheers, Peter
> On Feb 3, 2016, at 2:38 AM, Peter Moser <pitiz29a@gmail.com> wrote: > > Does anyone had similar problems? Do I have to configure Eclipse to understand the PG_RMGR macro or is there another possibilityto teach Eclipse these macros? I just built 9.6 under Eclipse CDT to try this out and was able to open e.g. heapam.c without any error markers. I added PostgreSQL as a “Makefile Project with Existing Code” after running ./configure from the command-line. After that,I built the project from within Eclipse by adding the ‘all’ make target and running it. One setting I usually change: right-click the project, pick Properties, then drill down through C/C++ General -> PreprocessorInclude Paths. In the Provider pane, there is an entry for “CDT GCC Build Output Parser”. I’m not sure if thisis strictly necessary, but I set my “Container to keep discovered entries” setting to “File”. Basically, Eclipse scans the make output for -I flags, then notes all the includes used to build each file, so the staticanalyzer, etc. can have more accurate information (it is crucial that the “Compiler command pattern” in this windowbe a regex that will match the compiler binary you use, so if you have /usr/local/bin/gcc, and “gcc” is the pattern,you are in for trouble). After running the build, Eclipse should now know what includes are used for each file and stop whining. If it ever seemsto have problems, you can kick it by running a clean target, then all, then picking “Project -> C/C++ Index -> Rebuild”(I think). -- Jason Petersen Software Engineer | Citus Data 303.736.9255 jason@citusdata.com
On 05.02.2016 um 18:40 Jason Petersen wrote: >> On Feb 3, 2016, at 2:38 AM, Peter Moser <pitiz29a@gmail.com> wrote: >> >> Does anyone had similar problems? Do I have to configure Eclipse to understand the PG_RMGR macro or is there another possibilityto teach Eclipse these macros? Hi, > > I just built 9.6 under Eclipse CDT to try this out and was able to open e.g. heapam.c without any error markers. > > I added PostgreSQL as a “Makefile Project with Existing Code” after running ./configure from the command-line. After that,I built the project from within Eclipse by adding the ‘all’ make target and running it. I imported PG the same way, configured from terminal with export CFLAGS="-g0" ./configure \ --prefix="/home/p/pg/build" \ --enable-debug \ --enable-depend \ --enable-cassert I built the project from command-line, not from within Eclipse. First I thought that this may have caused all this problems, but no... > > One setting I usually change: right-click the project, pick Properties, then drill down through C/C++ General -> PreprocessorInclude Paths. In the Provider pane, there is an entry for “CDT GCC Build Output Parser”. I’m not sure if thisis strictly necessary, but I set my “Container to keep discovered entries” setting to “File”. > > Basically, Eclipse scans the make output for -I flags, then notes all the includes used to build each file, so the staticanalyzer, etc. can have more accurate information (it is crucial that the “Compiler command pattern” in this windowbe a regex that will match the compiler binary you use, so if you have /usr/local/bin/gcc, and “gcc” is the pattern,you are in for trouble). > > After running the build, Eclipse should now know what includes are used for each file and stop whining. If it ever seemsto have problems, you can kick it by running a clean target, then all, then picking “Project -> C/C++ Index -> Rebuild”(I think). Thanks for all your suggestions, tried all of them, but it made no difference. What finally solved my problems was to delete the BUILD and cluster DATA folders that I had created, re-configured the system. Deleted the project in Eclipse, and imported it again after configure. All wrong markers disappeared. Maybe the C-file index of Eclipse was corrupted or so. Also rebuilding it didn't work. The only difference from my previous attempt was the CFLAGS thing (see above), but I do not know if this changes anything related to markers. ---- Peter > > -- > Jason Petersen > Software Engineer | Citus Data > 303.736.9255 > jason@citusdata.com >