Before logging an issue, please update to the latest release of Visual Micro from the Downloads Page.

When Logging a Support Issue in the Forum, please ensure you have also:-

  • Enabled vMicro > Compiler > Show Build Properties
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
  • Click the Reply button and attach as .txt file OR
  • Click here to Email us with the file attached, and a link to your post
Support requests without the output above may be impossible to answer, so please help us to help you
 
Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 8 Replies) warning: backslash and newline separated by space (Read 3900 times)
Red Baron
Member
***
Offline


Posts: 112
Location: Germany
Joined: Jul 29th, 2015
warning: backslash and newline separated by space
Oct 31st, 2022 at 10:31am
Print Post  
Using VM to compile a program for an ATtiny85 gives warning "backslash and newline separated by space" with multiline macros.

VM copies source files to %TEMP%\VMBUILDS\... When copying the files a space character is added to each line. CPP does not like this extra space character.

#define myMacro(a,b) \<CR><LF>
gives
#define myMacro(a,b) \<SP><CR><LF>

My sytem:
Microsoft Visual Studio Community 2022
Version 17.3.6
VisualStudio.17.Release/17.3.6+32929.385
Microsoft .NET Framework
Version 4.8.04084

Visual C++ 2022   00482-90000-00000-AA463
Microsoft Visual C++ 2022

Arduino IDE for Visual Studio by Visual Micro   22.0
Visual Micro is an Arduino Compatible IDE for Visual Studio 2022. For more information and forum please visit www.visualmicro.com.
  
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2695
Joined: Feb 13th, 2019
Re: warning: backslash and newline separated by space
Reply #1 - Oct 31st, 2022 at 10:40am
Print Post  
Thanks for the report.

Can you attach a copy of the full build output as a text file, with the options set as shown at the top of the page?
  
Back to top
IP Logged
 
Red Baron
Member
***
Offline


Posts: 112
Location: Germany
Joined: Jul 29th, 2015
Re: warning: backslash and newline separated by space
Reply #2 - Oct 31st, 2022 at 11:12am
Print Post  
I made a short sample that shows the problem.

I made a ZIP files with the project folder, the VMBuilds folder and the build output from VS. It's to big for an attachement (30MB). You can download it from here: https://ullisroboterseite.de/_forDownload/SpaceTest.zip

Let me know if you need more.
  
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2695
Joined: Feb 13th, 2019
Re: warning: backslash and newline separated by space
Reply #3 - Oct 31st, 2022 at 3:57pm
Print Post  
Thanks for the details and download.

The error is being shown as you have the vMicro > Compiler > Warnings for Project enabled, however the root of the issue is that the file does not end in a newline character.

If you click on line 4 in your Header.h, and press enter, then save and rebuild, the error should go away.

To my knowledge this is because of the language standards implemented by the compiler, and in many specs for C/C++ a source file which does not end in a new line can result in undefined behaviour, hence the warning.

Hopefully this helps to resolve the issue?
  
Back to top
IP Logged
 
Red Baron
Member
***
Offline


Posts: 112
Location: Germany
Joined: Jul 29th, 2015
Re: warning: backslash and newline separated by space
Reply #4 - Oct 31st, 2022 at 5:15pm
Print Post  
The warning is not critical. The compiler translates the code correctly.

For me compiler warnung are a helpful feature. Mostly they indicate a problem and maybe code will not work as expected. So I try to eliminate all warnings by clearing the code. If the compiler throws a warning, it tells me that I should revise the code. Unnecessary warnings are therefore very annoying.

The problem is a bug in VM. As described, VM appends a space character to each line when copying (at least for header files). The source code does not have an space character between the back slash and the line feed.

You should correct this in the next version.
  
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2695
Joined: Feb 13th, 2019
Re: warning: backslash and newline separated by space
Reply #5 - Oct 31st, 2022 at 6:41pm
Print Post  
Apologies for misunderstanding the issue, and I am currently unable to reproduce the issue even using your provided solution.

From the provided solution it seems the Header.h was added outside of Visual Studio, and has different line endings (LF) to the INO (CRLF) - which should be irrelevant.

Do you get the same problem when creating the Header.h file from the Solution Explorer in Visual Studio, and setting the line endings to CRLF in the code editor?

  
Back to top
IP Logged
 
Red Baron
Member
***
Offline


Posts: 112
Location: Germany
Joined: Jul 29th, 2015
Re: warning: backslash and newline separated by space
Reply #6 - Nov 1st, 2022 at 7:15am
Print Post  
I use VS2022 with default settings.

Header.h was created inside VS ("project-> add new element". I have a German version of VS. I don't know the exact English name of the menu item). It has line ending <CR><LF> .ino has line ending <LF>. I retested this. Maybe you got it mixed up?

I also tried "Add Empty Arduino .cpp and Header". Both (.cpp and .h) have line ending <CR><LF>.

The copy in VMBuilds has line ending <SP><LF>. <CR> is replaced by <SP>.

VM replaces <CR> by <SP> when copying the header file. See image problem1.png. I manually replaced <CR><LF> by <LF> in the header file. Now the problem disappears. 

I tried to compile with Arduino IDE 2.0.1. There the copy preserves <CR><LF>.

In my example there was another problem. The macro did not end with a line feed. But this gives another warning: "warning: backslash-newline at end of file".

Sometimes when opening a project VS asks me to normalize line endings. I always select "Windows (CRLF)".

-----
Since VS2022 there is another problem with "Show/Hide Hidden Files". User installed libraries are mostly not shown in the project explorer. To make shure I have a valid installation: Is it possible to deinstall VM an reinstall it witout loosing my licence?

  

Please Register or Login to the Forum to see File Attachments
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2695
Joined: Feb 13th, 2019
Re: warning: backslash and newline separated by space
Reply #7 - Nov 1st, 2022 at 10:46am
Print Post  
Thanks for the update and all of the detail supplied here, it has been extremely useful and we can now replicate the issue.

We will update this thread when there is a fix available for this issue.
  
Back to top
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2695
Joined: Feb 13th, 2019
Re: warning: backslash and newline separated by space
Reply #8 - Nov 3rd, 2022 at 3:36pm
Print Post  
Thanks for the detail around this, we have included a fix in the latest release (22.09.05.13) which should resolve this issue, and is available at the top of the board below:
https://www.visualmicro.com/forums/YaBB.pl?board=VS_ARDUINO_EXT_RELEASES
  
Back to top
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint