Thread overview | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
May 01, 2023 [Issue 23870] ImportC doesn't accept '\' followed by newline, whereas VC does | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23870 Walter Bright <bugzilla@digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bugzilla@digitalmars.com --- Comment #1 from Walter Bright <bugzilla@digitalmars.com> --- 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. ********************************************* This file is rejected by the gnu preprocessor with a warning: --- warning: backslash and newline separated by space [enabled by default] void test() { \ ^ --- and the \ is removed before the C compiler sees it. ********************************************** The Microsoft preprocessor passes it unchanged to the output. VC then rejects it with "error C2017: illegal escape sequence". ********************************************** The ImportC error diagnostic appears to be correct. That leaves the question, what is the context of this on your system? Is VC accepting it? -- |
May 01, 2023 [Issue 23870] ImportC doesn't accept '\' followed by newline, whereas VC does | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23870 --- Comment #2 from Max Samukha <maxsamukha@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. -- |
May 01, 2023 [Issue 23870] ImportC doesn't accept '\' followed by newline, whereas VC does | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23870 --- Comment #3 from Walter Bright <bugzilla@digitalmars.com> --- (In reply to Max Samukha from comment #2) > In the original test code, \ is immediately followed by a newline. You or your text editor must have added the space. I see you are right. I don't know how that space got in there! Running VC preprocessor without the trailing space still emits the \ into its output. (It should not do that.) This explains the behavior you are seeing. I'll see what I can do about it. Thanks for the help! -- |
May 01, 2023 [Issue 23870] ImportC doesn't accept '\' followed by newline, whereas VC does | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23870 --- Comment #4 from Max Samukha <maxsamukha@gmail.com> --- (In reply to Walter Bright from comment #3) > (It should not do that.) Note that VC compiler still accepts the code with the \. > I'll see what I can do about it. Nice, thanks! -- |
May 01, 2023 [Issue 23870] ImportC doesn't accept '\' followed by newline, whereas VC does | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23870 --- Comment #5 from Walter Bright <bugzilla@digitalmars.com> --- (In reply to Max Samukha from comment #4) > Note that VC compiler still accepts the code with the \. I know. It's still a bug in that compiler. I've noticed many times over the years that when there's a bug in VC, somebody writes code that relies on it. Sigh :-) -- |
May 01, 2023 [Issue 23870] ImportC doesn't accept '\' followed by newline, whereas VC does | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23870 Dlang Bot <dlang-bot@dlang.rocks> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |pull --- Comment #6 from Dlang Bot <dlang-bot@dlang.rocks> --- @WalterBright created dlang/dmd pull request #15157 "fix Issue 23870 - ImportC doesn't accept '\' followed by newline, whe…" fixing this issue: - fix Issue 23870 - ImportC doesn't accept '\' followed by newline, whereas VC does https://github.com/dlang/dmd/pull/15157 -- |
May 01, 2023 [Issue 23870] ImportC doesn't accept '\' followed by newline, whereas VC does | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23870 Dlang Bot <dlang-bot@dlang.rocks> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution|--- |FIXED --- Comment #7 from Dlang Bot <dlang-bot@dlang.rocks> --- dlang/dmd pull request #15157 "fix Issue 23870 - ImportC doesn't accept '\' followed by newline, whe…" was merged into master: - d4e10579275a360daf23b5853b0f8472df571b14 by Walter Bright: fix Issue 23870 - ImportC doesn't accept '\' followed by newline, whereas VC does https://github.com/dlang/dmd/pull/15157 -- |
Copyright © 1999-2021 by the D Language Foundation