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.
Summary: | "#pragma once" support in header files | ||
---|---|---|---|
Product: | cnd | Reporter: | rwerp <rwerp> |
Component: | -- Other -- | Assignee: | Vladimir Voskresensky <vv159170> |
Status: | RESOLVED DUPLICATE | ||
Severity: | normal | CC: | rwerp |
Priority: | P3 | ||
Version: | 7.1 | ||
Hardware: | PC | ||
OS: | Windows XP | ||
Issue Type: | ENHANCEMENT | Exception Reporter: |
Description
rwerp
2010-01-04 22:55:04 UTC
you can always modify template for header files yourself :-) The question if code assistance correctly understands #pragma once (I think it doesn't) To modify templates: Tools->Templates->C++->Header file choose Open In Editor, modify file, save it => newly created files will have content as you changed it Thanks, I'm a muppet :) btw, if you are interested 'pragma once' is obsolte. From preprocessor spec: --------- There is also an explicit directive to tell the preprocessor that it need not include a file more than once. This is called `#pragma once', and was used in addition to the `#ifndef' conditional around the contents of the header file. `#pragma once' is now obsolete and should not be used at all. -------- It was "un-obsoleted" in newere versions of gcc: http://gcc.gnu.org/onlinedocs/gcc-4.0.3/cpp/Obsolete-once_002donly-headers.html#Obsolete-once_002donly-headers "Another way to prevent a header file from being included more than once is with the `#pragma once' directive. If `#pragma once' is seen when scanning a header file, that file will never be read again, no matter what. `#pragma once' does not have the problems that `#import' does, but it is not recognized by all preprocessors, so you cannot rely on it in a portable program." Thanks for the link. So, we need to support it if we don't Sun Studio doesn't recognize "#pragma once" ------------------------------------------------ #include "test.h" #include "test.h" int main() { return 0; } ------------------------------------------------ #pragma once int f(){ return 0; } ------------------------------------------------ sova@sova:~$ gcc test.c sova@sova:~$ cc test.c "test.h", line 3: identifier redefined: f current : function() returning int previous: function() returning int : "test.h", line 3 cc: acomp failed for test.c I wonder if Netbeans have a plan to recognize "#pragma once". Our project uses "once", so it takes very long time to analyze project... (In reply to comment #8) > I wonder if Netbeans have a plan to recognize "#pragma once". It is supported (see issue #194887). What is your version of NB? Have you tried to give more memory to NB (-J-Xmx2G as netbeans param in command line)? Or use 32bit JVM? *** This bug has been marked as a duplicate of bug 194887 *** I think this is not resolved yet. For example test.h #ifdef ABCD_AAA #define ABCD_BBB #endif #define ABCD_AAA test.cpp #include "test.h" #include "test.h" ABCD_ If I add include guard to test.h, a code completion indicates only ABCD_AAA. But if I use #pragma once instead of include guard in test.h, the code completion indicates both definition. ABCD_AAA ABCD_BBB I know #pragma once is not portable, but my project has it. Please check this. Looks like a recent regression in 7.2 (see issue #217711) |