Line concatenation in define

Posted by: Andre81

Line concatenation in define - 22/08/2005 14:56

I've included some headers now and i get a parser error everywhere where i've used line concatenation in a define.

It compiles fine with VC++ but not with gcc. I know that this looks like a newbie question, but i really don't understand why i get a parse error.

Code:

#define x \
10

Posted by: Andre81

Re: Line concatenation in define - 22/08/2005 15:07

#define xxxxx \
blah


warning: blah declared as function returning a function

Posted by: peter

Re: Line concatenation in define - 22/08/2005 15:12

Quote:
Code:
#define x \
10


Should work fine. Is there any whitespace after the backslash? If you're using a Unix gcc, that may include CR.

Peter
Posted by: Andre81

Re: Line concatenation in define - 22/08/2005 15:56

In Antwort auf:
Is there any whitespace after the backslash? If you're using a Unix gcc, that may include CR.


No, just the required whitespace in front of the backslash. But i am using Visual Studio under Windows to edit my files, maybe gcc doesn't like the newline?
Posted by: Andre81

Re: Line concatenation in define - 22/08/2005 16:03

Ok, i've checked some other code for the empeg in the hex editor and my code, my code has a 0x0D 0x0A as a newline while the other had just a 0x0A.

After i've removed the 0x0D the file compiles.

Seems like i have a problem now
Posted by: Attack

Re: Line concatenation in define - 22/08/2005 17:02

Just get a dos2unix program. I know UltraEdit32 has it built in.
Posted by: wfaulk

Re: Line concatenation in define - 22/08/2005 17:02

Windows uses \r\n for EOLs and Unix uses just \n. The fact that you're editing Unix text files with a Windows text editor is 100% the problem. You can fix them after the fact with the nearly ubiquitous dos2unix command.
Posted by: Andre81

Re: Line concatenation in define - 24/08/2005 22:00

Here is a plug in for the Visual Studio that allows to set the end of line: http://www.codeguru.com/Cpp/V-S/devstudio_macros/textoperations/article.php/c3161/