🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.lang.c
Article #309935

Błąd preprocesora czy czegoś nie rozumiem?

#309935
From: M.M.
Date: Thu, 03 Oct 2019 20:19
28 lines
1745 bytes
Witam

Jest sobie poniższy program i działa:

#define TEST1( __x__ ) int __x__  = __LINE__
#define TEST2( __x__ ) int __x__  ## __LINE__ = 0

int main(int argc, char *argv[]) {
    TEST1( x );
    printf( "%d\n" , x );
//    TEST2( y );
//    TEST2( y );
    return 0;
}

Jednak jak odkomentuję dwie line:
//    TEST2( y );
//    TEST2( y );

to już mam błąd:

redeclaration of 'int y__LINE__'
     TEST2( y );
            ^

Od czego zależy kiedy rozwija makro __LINE__ a kiedy nie?

Pozdrawiam
Technical Details
Message-ID: <780a7f39-337b-4b6b-810f-7c4151e10f74@googlegroups.com>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!fu-berlin.de!feeder.usenetexpress.com!feeder-in1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!o24no3648885qtl.0!news-out.google.com!q23ni500qtl.1!nntp.google.com!o24no3648876qtl.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Received: by 2002:ac8:2e94:: with SMTP id h20mr12190058qta.234.1570133974873;        Thu, 03 Oct 2019 13:19:34 -0700 (PDT)
X-Received: by 2002:a81:3005:: with SMTP id w5mr7903628yww.472.1570133974719; Thu, 03 Oct 2019 13:19:34 -0700 (PDT)
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!fu-berlin.de!feeder.usenetexpress.com!feeder-in1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!o24no3648885qtl.0!news-out.google.com!q23ni500qtl.1!nntp.google.com!o24no3648876qtl.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
Newsgroups: pl.comp.lang.c
Date: Thu, 3 Oct 2019 13:19:34 -0700 (PDT)
Complaints-To: groups-abuse@google.com
Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=159.205.34.49; posting-account=xjvq9QoAAAATMPC2X3btlHd_LkaJo_rj
NNTP-Posting-Host: 159.205.34.49
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <780a7f39-337b-4b6b-810f-7c4151e10f74@googlegroups.com>
Subject: Błąd preprocesora czy czegoś
 nie rozumiem?
From: "M.M." <mmarszik@gmail.com>
Injection-Date: Thu, 03 Oct 2019 20:19:34 +0000
Lines: 28
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit