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 217711 - complain about recursive include while #pragma once guarding the file
Summary: complain about recursive include while #pragma once guarding the file
Status: RESOLVED FIXED
Alias: None
Product: cnd
Classification: Unclassified
Component: Code Model (show other bugs)
Version: 7.2
Hardware: PC Linux
: P3 normal (vote)
Assignee: Vladimir Voskresensky
URL:
Keywords: REGRESSION
Depends on:
Blocks:
 
Reported: 2012-09-02 14:45 UTC by igagis
Modified: 2012-09-04 01:10 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description igagis 2012-09-02 14:45:46 UTC
Create a header file named "sample.h" with the following contents:

===============================
#pragma once

class A{
public:
	int tratatatata;
};

#include "sample.h" //<--parser complains about recursive include directive
===============================

Result:
C++ code assistance complains about recursive include directive, although it does not make any harm because of #pragma once. Using #ifndef guards instead of #pragma once does not make any difference.
The problem is that in a large and complex project similar stuff makes parser stuck, it enters some kind of infinite loop and never completes the parsing of the project.

This would be useful for example if you have two classes depending on each other and you want to define their functions as inline:

==================================
file A.h:

#pragma once
class B;

class A{
public:
    int a;

    inline void func(const B& b);
}

#include "B.h"

inline void A::func(const B& b){
    b.b = 10;
}



=======================================
file B.h

#pragma once
class A;

class B{
public:
    int b;

    inline void func(const A& a);
}

#include "A.h"

inline void B::func(const A& a){
    a.a = 10;
}
Comment 1 Vladimir Voskresensky 2012-09-03 06:17:39 UTC
thanks for the report, I will investigate
Comment 2 Vladimir Voskresensky 2012-09-03 07:29:12 UTC
confirmed, it's a regression
Comment 3 Vladimir Voskresensky 2012-09-03 07:37:43 UTC
fixed + test
http://hg.netbeans.org/cnd-main/rev/2ead312d2b52

Thanks for catching!
Comment 4 Quality Engineering 2012-09-04 01:10:24 UTC
Integrated into 'main-golden', will be available in build *201209040001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/2ead312d2b52
User: Vladimir Voskresensky <vv159170@netbeans.org>
Log: fixed #217711 - complain about recursive include while #pragma once guarding the file