Thread: RE: [Dev-C++] Dev-C++ Bug? Using backslash within comments
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Reid T. <Rei...@at...> - 2005-07-06 14:36:34
|
Jonathan Dearborn wrote: > Here's an example program, though if you'd like to see the > compiled program > I found it on, check out > http://www.maybe-phil.net/websites/no-skill/jnrdev/en/jnrdev3/ >=20 > That program is based on SDL, so if you're not into that, > just use this one: > ----------------- >=20 > #include <stdio.h> > #include <iostream> >=20 > int main(int argc, char *argv[]) > { > int y; > int x =3D 200; > // let's cause a problem with backslash \ > y =3D x*55; > printf("%d\n",y); > system("PAUSE"); >=20 > printf("\n"); >=20 > // now without it > y =3D x*55; > printf("%d\n",y); > system("PAUSE"); > return 0; >=20 > // shouldn't the compiler ignore everything after these C++ style > comments? } >=20 >=20 > ------------------ > That about shows it. I know it's a little bother and I'm not > surprised it hasn't come up before, but I just wanted to help in case > someone else gets > stuck. Of course, it's only a problem with the C++ style comments. well, you just escaped the line ending character, basically telling the compiler suite that the comment line has not ended. The compiler will end the comment when it sees a valid line end. reid |
|
From: Reid T. <Rei...@at...> - 2005-07-06 17:30:06
|
Jonathan Dearborn wrote: > Reid, you're definitely right about escaping the line-break. That's > the problem, but is that a feature of the compiler (as Peter said) or > is it a little mistake in the compiler source? As I said before, > other compilers ignore the backslash if it's in a comment (as I > believe they should). Also, if it's a feature, shouldn't it be > useful? There is a separate comment style (the old style /*text*/) > in case you want to comment multiple lines. Escape characters > shouldn't affect comments. I think this is just a bug. A small bug, > but how should it be handled?=20 >=20 > Verne, are you saying your compiler gave a warning because there's > code after the main() return? That's fine, it's just a comment. I > would expect that. I use Dev-C++ exclusively for editing and > compiling, by the way.=20 >=20 > _________________________________________________________________ > Don't just search. Find. Check out the new MSN Search! > http://search.msn.click-url.com/go/onm00200636ave/direct/01/ SOLARIS SUN compiler $ CC -V CC: Sun C++ 5.5 2003/03/12 $ CC test.C does not ignore it "test.C", line 11: Warning: The variable y has not yet been assigned a value. 1 Warning(s) detected. NOTE: The other compilers may very well output a similar warning IF you pass the proper flags. EXAMPLE: cygwin compiler called 'g++ -Wall' declares=20 $ g++ -Wall test.cpp test.cpp:9:5: warning: multi-line comment SOLARIS gcc $ g++ -v Reading specs from /usr/local/lib/gcc-lib/sparc-sun-solaris2.6/2.95.2/specs gcc version 2.95.2 19991024 (release) does not ignore it AIX $ cc -v exec: /usr/bin/pg(/usr/bin/pg,/usr/lib/nls/msg/en_US/vacpp.help,NULL)=20 VisualAge C++ Professional / C for AIX Compiler, Version 6 does not ignore it CYGWIN $ g++ -v Reading specs from /usr/lib/gcc/i686-pc-cygwin/3.4.4/specs Configured with: /gcc/gcc-3.4.4/gcc-3.4.4-1/configure --verbose --prefix=3D/usr --exec-prefix=3D/usr --sysconfdir=3D/etc = --libdir=3D/usr/lib --libexecdir=3D/usr/lib --mandir=3D/usr/share/man = --infodir=3D/usr/share/info --enable-languages=3Dc,ada,c++,d,f77,java,objc --enable-nls --without-included-gettext --enable-version-specific-runtime-libs --without-x --enable-libgcj --disable-java-awt --with-system-zlib --enable-interpreter --disable-libgcj-debug --enable-threads=3Dposix --enable-java-gc=3Dboehm --disable-win32-registry = --enable-sjlj-exceptions --enable-hash-synchronization --enable-libstdcxx-debug : (reconfigured)=20 Thread model: posix gcc version 3.4.4 (cygming special) (gdc 0.12, using dmd 0.125) does not ignore it So, based on empirical evidence, no, prob not a bug. reid |
|
From: Reid T. <Rei...@at...> - 2005-07-06 17:38:41
|
Reid Thompson wrote: > Jonathan Dearborn wrote: a question, what are the 'other' compiler you mention? reid |
|
From: Reid T. <Rei...@at...> - 2005-07-06 18:16:06
|
Reid Thompson wrote: one more that I remembered that I had... also ignores it... C:\>cl /? Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.10.3077 for 80x86 Copyright (C) Microsoft Corporation 1984-2002. All rights reserved. ... c:\test.cpp(11) : warning C4700: local variable 'y' used without having been ini tialized Microsoft (R) Incremental Linker Version 7.10.3077 Copyright (C) Microsoft Corporation. All rights reserved. /out:test.exe test.obj C:\>test.exe 29721173 Press any key to continue . . . 11000 Press any key to continue . . . reid |
|
From: Jonathan D. <gri...@ho...> - 2005-07-06 18:56:48
|
Well, Reid, that sounds like good enough evidence. I'm not positive on what the "other" compiler is, but I think it is Visual C++. At any rate, thanks for clearing that up. In my opinion, it shouldn't be read by the compiler because the preprocessor should take out all commented text. Maybe I've just never heard of extending a one-line comment and this is how it's done. I didn't want Dev-C++ to be the odd one out if more compilers ignored it (since I only use Dev-C++). I now doubt that it'll ever be a big enough problem unless this rarely-used feature to overlook backslashes at the end of comments in a (most likely) single compiler is used in popular free source. I don't see that happening more than where I got it from. Thanks for your help, Reid. _________________________________________________________________ Express yourself instantly with MSN Messenger! Download today - it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/ |
|
From: Peter B. <pb...@hg...> - 2005-07-07 07:50:04
|
Jonathan Dearborn wrote: (...) > this is how it's done. I didn't want Dev-C++ to be the odd one out if > more compilers ignored it (since I only use Dev-C++). I now doubt that (...) BTW, not Dev-C++ is the compiler it's gcc which is called by Dev-C++ to do the compilation. So the problem should not be addressed to the Dev-C++ but to the gcc developers. Peter |
|
From: Reid T. <Rei...@at...> - 2005-07-06 19:21:59
|
Jonathan Dearborn wrote: > Well, Reid, that sounds like good enough evidence. I'm not positive > on what the "other" compiler is, but I think it is Visual C++. At > any rate, thanks for clearing that up. =20 > In my opinion, it shouldn't > be read by the compiler because the preprocessor should take out all > commented text.=20 That is what is happening, the line following the 'intended' comment line with the terminating '\' is considered as part of the 'intended' comment and is being handled as such ( i.e. it is not converted to executable form by the compiler -- whether that means that it is not passed to the compiler, or is passed but is ignored by the compiler 'because it's a comment' I don't know.) >Maybe I've just never heard of extending a one-line > comment and this is how it's done. I didn't want Dev-C++ to be the > odd one out if more compilers ignored it (since I only use Dev-C++).=20 > I now doubt that it'll ever be a big enough problem unless this > rarely-used feature to overlook backslashes at the end of comments in > a (most likely) single compiler is used in popular free source. I > don't see that happening more than where I got it from. Thanks for > your help, Reid.=20 >=20 > _________________________________________________________________ > Express yourself instantly with MSN Messenger! Download today - it's > FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/ reid |
|
From: Jonathan D. <gri...@ho...> - 2005-07-06 16:55:58
|
Reid, you're definitely right about escaping the line-break. That's the problem, but is that a feature of the compiler (as Peter said) or is it a little mistake in the compiler source? As I said before, other compilers ignore the backslash if it's in a comment (as I believe they should). Also, if it's a feature, shouldn't it be useful? There is a separate comment style (the old style /*text*/) in case you want to comment multiple lines. Escape characters shouldn't affect comments. I think this is just a bug. A small bug, but how should it be handled? Verne, are you saying your compiler gave a warning because there's code after the main() return? That's fine, it's just a comment. I would expect that. I use Dev-C++ exclusively for editing and compiling, by the way. _________________________________________________________________ Dont just search. Find. Check out the new MSN Search! http://search.msn.click-url.com/go/onm00200636ave/direct/01/ |