public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/37267]  New: #pragma inside structure initialization causes error
@ 2008-08-28 18:51 neale at sinenomine dot net
  2008-09-02 20:54 ` [Bug c/37267] [4.2/4.3/4.4 Regression] " pinskia at gcc dot gnu dot org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: neale at sinenomine dot net @ 2008-08-28 18:51 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1329 bytes --]

We’ve implemented the #pragma ident which simply generates information in the
comment section of an elf object. Solaris uses it throughout its source tree.
However, it’s causing some grief when used in a manner like this:

#include <stdio.h>

typedef struct X {
        int a;
        int b;
} X_t;

int z;

X_t x[] = {
#pragma weak Y = z
{0,1},
{2,3}
};

int 
main(int argc, char **argv) 
{
        printf("%x",x[0].a);
        return x[1].b;
}


I’ve replaced ident with weak so it will run on other platforms. For gcc 4.0.1
there’s no problem but with 4.2.3 I get the following:

/tmp/test.c:11: error: expected expression before '#pragma'

The context in which I am seeing a problem is that the C code does something
like this:

tuple_t x[] = {
#include “a.h”
#include “b.h”
};

Each of the ‘.h’ files have the contents of the structure but they also contain
a #pragma ident which causes the compiler to emit the error.

Neale


-- 
           Summary: #pragma inside structure initialization causes error
           Product: gcc
           Version: 4.2.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: neale at sinenomine dot net


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


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

end of thread, other threads:[~2008-10-22  3:51 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-28 18:51 [Bug c/37267] New: #pragma inside structure initialization causes error neale at sinenomine dot net
2008-09-02 20:54 ` [Bug c/37267] [4.2/4.3/4.4 Regression] " pinskia at gcc dot gnu dot org
2008-09-03  9:42 ` jakub at gcc dot gnu dot org
2008-09-03  9:49 ` jakub at gcc dot gnu dot org
2008-09-20 14:36 ` rguenth at gcc dot gnu dot org
2008-09-21 16:14 ` joseph at codesourcery dot com
2008-10-22  3:51 ` mmitchel at gcc dot gnu 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).