public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug preprocessor/52566] New: #include in c++ namespace scope doesn't work properly
@ 2012-03-12 16:25 shihjr at gmail dot com
  2012-03-12 16:31 ` [Bug preprocessor/52566] " redi at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: shihjr at gmail dot com @ 2012-03-12 16:25 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52566

             Bug #: 52566
           Summary: #include in c++ namespace scope doesn't work properly
    Classification: Unclassified
           Product: gcc
           Version: 4.4.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: preprocessor
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: shihjr@gmail.com


# gcc --version
gcc (Ubuntu 4.4.3-4ubuntu5) 4.4.3

3 source files: ns1.h ns2.h test.cpp

---------------------------------------------------------
ns1.h:
#pragma once
class A
{
};
---------------------------------------------------------
ns2.h:
#pragma once
class A
{
};
---------------------------------------------------------
test.cpp:
namespace NS1
{
#include "ns1.h"
}
namespace NS2
{
#include "ns2.h"
}
int main()
{
    NS2::A a;
    return 0;
}
---------------------------------------------------------

# touch *   // important step, let ns1.h and ns2.h have same modification time
# gcc test.cpp
test.cpp: In function 'int main()':
test.cpp:11: error: 'A' is not a member of 'NS2'
test.cpp:11: error: expected ';' before 'a'

# gcc -c -E test.cpp
# 1 "test.cpp"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "test.cpp"
namespace NS1
{
# 1 "ns1.h" 1

class A
{
};
# 4 "test.cpp" 2
}
namespace NS2
{

}
int main()
{
    NS2::A a;
    return 0;
}

----------------------------------------------------
The NS2::A declaration isn't included in namespace NS2


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug preprocessor/52566] #include in c++ namespace scope doesn't work properly
  2012-03-12 16:25 [Bug preprocessor/52566] New: #include in c++ namespace scope doesn't work properly shihjr at gmail dot com
@ 2012-03-12 16:31 ` redi at gcc dot gnu.org
  2012-03-12 17:10 ` jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2012-03-12 16:31 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52566

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-03-12 16:30:32 UTC ---
this has nothing to do with namespace scope, it's #pragma once confusing two
separate files as one


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug preprocessor/52566] #include in c++ namespace scope doesn't work properly
  2012-03-12 16:25 [Bug preprocessor/52566] New: #include in c++ namespace scope doesn't work properly shihjr at gmail dot com
  2012-03-12 16:31 ` [Bug preprocessor/52566] " redi at gcc dot gnu.org
@ 2012-03-12 17:10 ` jakub at gcc dot gnu.org
  2012-03-14 10:48 ` redi at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-03-12 17:10 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52566

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-03-12 17:09:37 UTC ---
You either should have different content of the two headers, or don't use
#pragma once, or you need to have different timestamps.  In order to support
symlinks/hardlinks and also lame filesystems that lack them, the preprocessor
only looks at file sizes/timestamps and content if there are multiple #pragma
once (or #import) headers.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug preprocessor/52566] #include in c++ namespace scope doesn't work properly
  2012-03-12 16:25 [Bug preprocessor/52566] New: #include in c++ namespace scope doesn't work properly shihjr at gmail dot com
  2012-03-12 16:31 ` [Bug preprocessor/52566] " redi at gcc dot gnu.org
  2012-03-12 17:10 ` jakub at gcc dot gnu.org
@ 2012-03-14 10:48 ` redi at gcc dot gnu.org
  2022-12-14 13:19 ` [Bug preprocessor/52566] #include with #pragma once and files' contents is the same pinskia at gcc dot gnu.org
  2022-12-14 13:27 ` terra at gnome dot org
  4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2012-03-14 10:48 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52566

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-03-14 10:46:54 UTC ---
If you want to use #pragma once the simplest solution might be to put a unique
comment in each file, with e.g. just the filename, or a description of its
purpose


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug preprocessor/52566] #include with #pragma once and files' contents is the same
  2012-03-12 16:25 [Bug preprocessor/52566] New: #include in c++ namespace scope doesn't work properly shihjr at gmail dot com
                   ` (2 preceding siblings ...)
  2012-03-14 10:48 ` redi at gcc dot gnu.org
@ 2022-12-14 13:19 ` pinskia at gcc dot gnu.org
  2022-12-14 13:27 ` terra at gnome dot org
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-12-14 13:19 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52566

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |terra at gnome dot org

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 108101 has been marked as a duplicate of this bug. ***

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug preprocessor/52566] #include with #pragma once and files' contents is the same
  2012-03-12 16:25 [Bug preprocessor/52566] New: #include in c++ namespace scope doesn't work properly shihjr at gmail dot com
                   ` (3 preceding siblings ...)
  2022-12-14 13:19 ` [Bug preprocessor/52566] #include with #pragma once and files' contents is the same pinskia at gcc dot gnu.org
@ 2022-12-14 13:27 ` terra at gnome dot org
  4 siblings, 0 replies; 6+ messages in thread
From: terra at gnome dot org @ 2022-12-14 13:27 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52566

--- Comment #5 from M Welinder <terra at gnome dot org> ---
From 108101:

Note also:

# gcc -MM c.c
c.o: c.c a.h

No b.h present!

I.e., Makefiles built with this will not pick up changes to the second file.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-12-14 13:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-12 16:25 [Bug preprocessor/52566] New: #include in c++ namespace scope doesn't work properly shihjr at gmail dot com
2012-03-12 16:31 ` [Bug preprocessor/52566] " redi at gcc dot gnu.org
2012-03-12 17:10 ` jakub at gcc dot gnu.org
2012-03-14 10:48 ` redi at gcc dot gnu.org
2022-12-14 13:19 ` [Bug preprocessor/52566] #include with #pragma once and files' contents is the same pinskia at gcc dot gnu.org
2022-12-14 13:27 ` terra at gnome dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).