Bug 17853 - Compiler warnings
Compiler warnings
Product: Red Hat Linux
Classification: Retired
Component: gcc (Show other bugs)
i686 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Depends On:
  Show dependency treegraph
Reported: 2000-09-26 05:59 EDT by Jimmy Timofte
Modified: 2008-05-01 11:37 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2000-09-26 05:59:22 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Jimmy Timofte 2000-09-26 05:59:20 EDT
The gcc compiler gives some warning messages when trying to compile the
following examples:

#define CLASS(NAME) \
class NAME \
{ \
    public: \
    NAME() {}; \
    ~##NAME() {}; \
} \
void main() {}

/* example2.c */
#define CLASS(NAME) \
class NAME \
{ \
    public: \
    NAME(); \
}; \
NAME##::##NAME() {};
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

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

Comment 1 Jakub Jelinek 2000-09-26 07:14:48 EDT
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 07:24:13 EDT
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 08:23:13 EDT
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.