eclipse code analysis problem in modular projects

140 views
Skip to first unread message

SebG

unread,
Jan 28, 2016, 5:03:34 AM1/28/16
to deal.II User Group
Dear deal.ii-users,

I am trying to setup a bigger modular deal.II project in eclipse. But I am somehow getting errors (Code Analysis Problems) in eclipse. As dummy test I took the step-3 tutorial program. I set up an eclipse project using cmake and the generator option.

Then I modularized the program using the following structure:
./main.cc
./include/Step3.h
./include/dealiiInclude.h
./source/Step3.cc

and I adjust the CMakeList.txt file

SET(TARGET "main")
FILE(GLOB_RECURSE TARGET_SRC  "source/*.cc")
FILE(GLOB_RECURSE TARGET_INC  "include/*.h")
SET(TARGET_SRC ${TARGET_SRC}  ${TARGET_INC} ${TARGET}.cc)

and ran cmake again.

The weird thing is that the program compiles and runs fine. But eclipse shows me strange errrors (Code Analysis Problem) such as

The type 'dealii::FE_Q' must implement the inherited pure virtual method 'dealii::FiniteElement::fill_fe_face_values'.

I already tried: Index->Rebuild.

I don't understand this. If the program compiles there should not exists any errors, only warnings, right? Is there something with my eclipse version? I am using Mars.1 Release (4.5.1).

Best
Sebastian







Wolfgang Bangerth

unread,
Jan 28, 2016, 7:41:54 AM1/28/16
to dea...@googlegroups.com
On 01/28/2016 04:03 AM, SebG wrote:
>
>
> I don't understand this. If the program compiles there should not exists any
> errors, only warnings, right? Is there something with my eclipse version? I am
> using Mars.1 Release (4.5.1).

Eclipse is not a compiler. It tries to parse the code in some kind of
heuristic way (for example, it does not try to exactly follow for which
template arguments you are trying to instantiate things) and it sometimes gets
it wrong.

C++ is a complicated language. It would require a far more complicated parser
(and *much* more CPU time) for eclipse to correctly understand your code. The
eclipse errors are simply a representation of this incorrect understanding.

Best
W.

--
------------------------------------------------------------------------
Wolfgang Bangerth email: bang...@math.tamu.edu
www: http://www.math.tamu.edu/~bangerth/

SebG

unread,
Jan 30, 2016, 11:57:29 AM1/30/16
to deal.II User Group
Thank you, Wolfgang, for your reply. I understood that these errors are just parse errors by eclipse.

A colleague and I wrote a longer deal.ii code, ~1500 lines, which we would like to separate in multiple files contained in subdirectories. We have already written a version in which every class has a header file and  header file for the implementation. Something like SolverBase.h and SolverBase_impl.h. Eclipse is able to parse this code without any errors or warnings, which surprised use.

Instead of the quick hack of writing implementation header files, we would like to create a classical structure using one or multiple include and source directories. As far as I know, every implementation file then needs to contain an explicit instantiation of the functions and classes. Is that correct?

Another question is how cmake needs to be configured. Do I need to create libraries as described in the users guide? What file system structure would recommend for a larger project? I was thinking of something like

./main.cc
./Preprocessing/include
./Preprocessing/source
./Postprocessing/include
./Postprocessing/source

and so on.

Many thanks in advance.

Best regards
Sebastian

Wolfgang Bangerth

unread,
Jan 31, 2016, 12:54:34 PM1/31/16
to dea...@googlegroups.com

> A colleague and I wrote a longer deal.ii code, ~1500 lines, which we would
> like to separate in multiple files contained in subdirectories. We have
> already written a version in which every class has a header file and header
> file for the implementation. Something like SolverBase.h and
> SolverBase_impl.h. Eclipse is able to parse this code without any errors or
> warnings, which surprised use.
>
> Instead of the quick hack of writing implementation header files, we would
> like to create a classical structure using one or multiple include and source
> directories. As far as I know, every implementation file then needs to contain
> an explicit instantiation of the functions and classes. Is that correct?

Correct.


> Another question is how cmake needs to be configured. Do I need to create
> libraries as described in the users guide? What file system structure would
> recommend for a larger project? I was thinking of something like
>
> ./main.cc
> ./Preprocessing/include
> ./Preprocessing/source
> ./Postprocessing/include
> ./Postprocessing/source
>
> and so on.

Take a look at the description here
https://www.dealii.org/developer/users/cmakelists.html
for an already complete CMakeLists.txt file that supports a similar file
structure.
Reply all
Reply to author
Forward
0 new messages