Bug 17853 - Compiler warnings
Summary: Compiler warnings
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: gcc
Version: 7.0
Hardware: i686
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2000-09-26 09:59 UTC by Jimmy Timofte
Modified: 2008-05-01 15:37 UTC (History)
0 users

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2000-09-26 09:59:22 UTC
Embargoed:


Attachments (Terms of Use)

Description Jimmy Timofte 2000-09-26 09:59:20 UTC
The gcc compiler gives some warning messages when trying to compile the
following examples:

/*example1.c*/
#define CLASS(NAME) \
class NAME \
{ \
    public: \
    NAME() {}; \
    ~##NAME() {}; \
} \
 
CLASS(Test);
 
void main() {}


/* example2.c */
#define CLASS(NAME) \
class NAME \
{ \
    public: \
    NAME(); \
}; \
\
NAME##::##NAME() {};
 
CLASS(Test)
 
void main() {}

Here is the output for the compiling of example1.c:
[jimmy@chopin test]$ g++ example1.c
example1.c:7:5: warning: nothing can be pasted after this token    

Here is the output for the compiling of example2.c:
[jimmy@chopin test]$ g++ example2.c
example2.c:9:7: warning: nothing can be pasted after this token
example2.c:11:11: warning: pasting would not give a valid preprocessing
token 

The examples were compiled using g++ version 2.96:
[jimmy@chopin test]$ g++ --version
2.96

That's
all

Comment 1 Jakub Jelinek 2000-09-26 11:14:48 UTC
The warnings are appropriate here, there is no need to put ## between
~ and identificator or between identificator and scope (::). The preprocessor
really cannot paste the two tokens together, previous preprocessors silently
ignored this.
Either remove all ## from your examples (none of them are needed), all compile
with -Wno-paste to avoid emiting those warnings.

Comment 2 Enrico Scholz 2000-09-26 11:24:13 UTC
You program is wrong. The C++ standard says at 16.3.3/1:

| A ## preprocessing token shall not occur at the beginning or at the end of a
replacement list for 
| either form of macro definition.

It's better to write `~NAME' and `NAME::NAME'  directly.

Comment 3 Jimmy Timofte 2000-09-26 12:23:13 UTC
Thank you very much.
Anyway, this is not really my program. These warnings appeared when compiling
mysql++ v1.7.5 module.
Thank you for your quick response.


Note You need to log in before you can comment on or make changes to this bug.