Bug 17853

Summary: Compiler warnings
Product: [Retired] Red Hat Linux Reporter: Jimmy Timofte <jimmyt_104>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED NOTABUG QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 7.0   
Target Milestone: ---   
Target Release: ---   
Hardware: i686   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2000-09-26 09:59:22 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

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.