[Issue 23870] ImportC doesn't accept '\' followed by newline, whereas VC does

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon May 1 03:09:28 UTC 2023


https://issues.dlang.org/show_bug.cgi?id=23870

--- Comment #2 from Max Samukha <maxsamukha at gmail.com> ---
(In reply to Walter Bright from comment #1)
> This is invalid C code. The problem is the \ is followed by a space. The
> backslash line splicing done by the preprocessor happens only when the \ is
> followed by a newline.

In the original test code, \ is immediately followed by a newline. You or your
text editor must have added the space.



> This file is rejected by the gnu preprocessor with a warning:

I didn't test it with anything other than VC. VC happens to accept backslash
line continuations outside macros. See
https://learn.microsoft.com/en-us/cpp/c-language/escape-sequences?view=msvc-170:

"You can also use the backslash (\) as a continuation character. When a newline
character (equivalent to pressing the RETURN key) immediately follows the
backslash, the compiler ignores the backslash and the newline character and
treats the next line as part of the previous line. This is useful primarily for
preprocessor definitions longer than a single line.".

> That leaves the question, what is the context of this on your system? Is VC accepting it?

Yes, VC is mentioned in the bug report's title.

The test code was extracted from "shared\winerror.h", line 39382, of Windows
SDK.

How do you test ImportC on Windows? I suggest trying it on "um/Windows.h". If
ImportC can handle that, most of headers on Windows will be covered, I believe.

--


More information about the Digitalmars-d-bugs mailing list