By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,778 Members | 2,015 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,778 IT Pros & Developers. It's quick & easy.

Different behavior from __LINE__ macro in g++ 2.95.x and 3.x

P: n/a
On g++ version 3.X I get the "wrong" line number, 8 reported
for the following code:

1 #include <iostream>
2 using namespace std;
3 int main(void)
4 {
5 ^M^M^Mcout << "file:" << __FILE__ << " line:" << __LINE__ << endl;
6 }
7 /*
8 3 ^Ms on cout line 5 code reports
9 file:wrongLine.C line:8
10 */

where ^M denotes control-M.

Does this conform to standard? 2.95.x version's I've tried
"correctly" report 5.

Thanks in advance for your reply.

Gary

Jul 23 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On 22 Feb 2005 17:06:01 -0800, us****@sta.samsung.com wrote in
comp.lang.c++:
On g++ version 3.X I get the "wrong" line number, 8 reported
for the following code:

1 #include <iostream>
2 using namespace std;
3 int main(void)
4 {
5 ^M^M^Mcout << "file:" << __FILE__ << " line:" << __LINE__ << endl;
6 }
7 /*
8 3 ^Ms on cout line 5 code reports
9 file:wrongLine.C line:8
10 */

where ^M denotes control-M.

Does this conform to standard? 2.95.x version's I've tried
"correctly" report 5.

Thanks in advance for your reply.

Gary


Since the code sample you posted has illegal characters in it, the C++
language does not specify the behavior.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Jul 23 '05 #2

P: n/a
On 22 Feb 2005 17:06:01 -0800, us****@sta.samsung.com wrote:
On g++ version 3.X I get the "wrong" line number, 8 reported
for the following code:

1 #include <iostream>
2 using namespace std;
3 int main(void)
4 {
5 ^M^M^Mcout << "file:" << __FILE__ << " line:" << __LINE__ << endl;
6 }
7 /*
8 3 ^Ms on cout line 5 code reports
9 file:wrongLine.C line:8
10 */

where ^M denotes control-M.

Does this conform to standard? 2.95.x version's I've tried
"correctly" report 5.


[semi-ot for CLC]
'^M' is one of the characters used to denote a newline. Two other
combinations can be '^J' and the '^M^J' pair.

The actual newline information used is system-dependant. In this case, it
looks like G++ is attempting to intellegently detect which newline is in
use (Dos/Unix compatability), causing the difference between Line numbers.
[/ot]

Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.