Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] Cycling pound includes check?

Since it is legal in C to include headers multiple times it is not up to CDT to prevent that. It sounds more like a job for static analysis plugin.

Since CDT tells me right away if I have included header file that doesn't exist, could this circular check be added as well. From the high level it doesn't seem hard to do so, but things could be different down below.

There is static analysis framework started in CDT called Codan. You may want to raise a bug against that in Bugzilla. If you are interested in this particular check and up to coding contributions are welcome.

Andrew 

On Fri, Jul 24, 2009 at 11:15 AM, Fedja Jeleskovic <mrawd2@xxxxxxxxx> wrote:
No, it will not! The thing is that second file can't find things from the first one and gives strange errors along the way. Basically any cpp file including one of those directly or through some other header file will give you a very strange and not easy to trace error during the compilation. At least that is the case with code that I build for the VxWorks on the Linux platform.


On Fri, Jul 24, 2009 at 10:53 AM, Elena Laskavaia <elaskavaia@xxxxxxx> wrote:
This is ok to do as long as your headers are guarded which is 99% of cases for c programming. If you create new header file using CDT it would be guarded by default.


Fedja Jeleskovic wrote:
I probably wasn't clear on what I was asking. Here is an example to make things more clear.
File1.h:
#include <File2.h>

File2.h:
#include <File1.h>

Compiler freaks about this and gives quite strange error, but this condition should be easy to spot just the way missing header files are spotted today.

Hope this is more clear.


Fedja

On Fri, Jul 24, 2009 at 3:56 AM, Schorn, Markus <Markus.Schorn@xxxxxxxxxxxxx <mailto:Markus.Schorn@xxxxxxxxxxxxx>> wrote:

   Hi,
   it is legal and quite normal to include the same file in a
   translation unit mor than once. Issuing a warning about it
   would not be the right thing to do.
   Neither a compiler nor a parser has a reasonable way to check
   whether a recursive inclusion is handled properly    within the header. It just has to perform the inclusion and
   typically aborts the process at a certain recursion depth.
       Markus.
       
       ------------------------------------------------------------------------
       *From:* cdt-dev-bounces@xxxxxxxxxxx
       <mailto:cdt-dev-bounces@xxxxxxxxxxx>
       [mailto:cdt-dev-bounces@xxxxxxxxxxx
       <mailto:cdt-dev-bounces@xxxxxxxxxxx>] *On Behalf Of *Fedja
       Jeleskovic
       *Sent:* Thursday, July 23, 2009 8:20 PM
       *To:* CDT General developers list.
       *Subject:* [cdt-dev] Cycling pound includes check?
       *Importance:* Low

       I have been hit several times lately with cycling pound
       includes in the code and unfriendliness of the compiler
       regarding the issues like that. The error shows up at the
       strange place and it takes a while to trace it down just to
       find out that someone included a header file that had it
       already included before.

       Since CDT tells me right away if I have included header file
       that doesn't exist, could this circular check be added as
       well. From the high level it doesn't seem hard to do so, but
       things could be different down below.

       Let me know!

       Thanks.

       Fedja


   _______________________________________________
   cdt-dev mailing list
   cdt-dev@xxxxxxxxxxx <mailto:cdt-dev@xxxxxxxxxxx> ------------------------------------------------------------------------


_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/cdt-dev
 
_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/cdt-dev


_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/cdt-dev



Back to the top