Wrap the message of the #error directive, based on the following (all
excerpts from C99):
- 5.1.1.2 Translation phases, p1, phase 2:
Each instance of a backslash character (\) immediately followed by a
new-line character is deleted, splicing physical source lines to form
logical source lines. [...]"
- 5.1.1.2 Translation phases, p1, phase 3:
The source file is decomposed into preprocessing tokens [...] and
sequences of white-space characters (including comments). [...] New-line
characters are retained. Whether each nonempty sequence of white-space
characters other than new-line is retained or replaced by one space
character is implementation-defined.
- 6.10.5 Error directive, p1:
A preprocessing directive of the form
# error pp-tokens opt new-line
causes the implementation to produce a diagnostic message that includes
the specified sequence of preprocessing tokens.
This means that the #error directive does not need a string literal
(preprocessing tokens are a lower-level concept), and that we can break
the sequence of pp-tokens to multiple physical lines with backslashes, and
that an implementation may or may not squeeze our multiple space
characters (even before the patch, after the full stop!) into single space
characters.
In practice, when forcing the #error post-patch, gcc prints (not wrapped
here intentionally):
handle.c:29:2: error: #error These bindings will not work with Python
2. Recompile using Python 3 or use ./configure --disable-python.
29 | #error \
| ^~~~~
IOW, gcc does squeeze the space characters.
Bugzilla:
https://bugzilla.redhat.com/show_bug.cgi?id=2172516
Signed-off-by: Laszlo Ersek <lersek(a)redhat.com>
---
python/handle.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/python/handle.c b/python/handle.c
index 29a612bbe5f5..2b04cdcda89f 100644
--- a/python/handle.c
+++ b/python/handle.c
@@ -26,7 +26,9 @@
#include <Python.h>
#if PY_MAJOR_VERSION == 2
-#error "These bindings will not work with Python 2. Recompile using Python 3 or use
./configure --disable-python."
+#error \
+ These bindings will not work with Python 2. \
+ Recompile using Python 3 or use ./configure --disable-python.
#endif
#include <stdio.h>