Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

escape-sequence compile problems

Status
Not open for further replies.

DoraC

Programmer
May 7, 2002
98
US
Hi,

I'm using (trying.. to use) Visual C++ 6.0 to compile
a bison-generated parser (the x.tab.c file). However, the bison program I'm using generates these .c files with code
something along the lines of the following:

Code:
#line 1 "C:\my\bison\project\home\bison_project.y"

The backslashes cause vc++ (a command-line compile, btw) to choke hard... a slew of "unrecognized character escape sequence" errors are generated. I would certainly just change the backslashes to either "\\" or "/" (which should and probably would work), but certain generated variables I don't have easy access to prevent this from being a solution. I need to - somehow - tell vc++ to permit backslashes in the code. Is there a way to do this?

Any help would be very much appreciated,
Thanks,
dora
p.s. - is anyone aware of flex/bison binaries available for download that are compatible with vc++?
 
no, there is no way of "telling" VC++ to allow single slashes, its part of the C/C++ language that a "\" is an escape character

i dont know if this works with VC++ (it does with c#) is to use

char* szVariable = @"C:\Dir\My Dir\File 1.xls";

the @ tells it to ignore "\"'s
 
On the bright side, depending on the amount of files generated, you could do a find and replace with regular expressions to replace any \ in a quoted string with \\ or write up a quick parser that replaces a sing \ with \\.

If this is your only problem with the generated code, it should be fine.

Matt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top