Reputation: 27581
Here a code to demonstrate an annoying problem:
class A {
public:
A():
m_b(1),
m_a(2)
{}
private:
int m_a;
int m_b;
};
This is an output on Console view:
make all
Building file: ../test.cpp
Invoking: GCC C++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"test.d" -MT"test.d" -o"test.o" "../test.cpp"
../test.cpp: In constructor 'A::A()':
../test.cpp:9: warning: 'A::m_b' will be initialized after
../test.cpp:8: warning: 'int A::m_a'
../test.cpp:3: warning: when initialized here
Finished building: ../test.cpp
The problem is that in Problems view I'll see 3 separate warnings (lines in output containing warning word), while indeed there're 4 lines in output describing a one problem.
Is there're something I'm missing?
Additional question. Maybe it's in Eclipse spirit, but is there a way to make Console view clickable as most IDE does (e.g. Visual Studio, emacs ...)
Thanks Dima
Upvotes: 4
Views: 4188
Reputation: 1
Thanks David, but I think you may have misunderstood me. I was referring to the fact that the 'Problems' view in eclipse sorts the compiler errors alphabetically by default. As Dima was saying this causes problem with gcc error messages which are spread over two lines such as
as all the 'within this context' lines get separated from the variable they are referring to.
HOWEVER, I just found the option to change the sorting order of the compiler errors, the little downwards pointing triangle at the top of the view (only just worked out this is where you set the options for the view as I am new to eclipse). If you play around with this it will help but will still not be able stop errors in the same file from being jumbled (why isn't there an option just leave them as they were?)
Upvotes: 0
Reputation: 1260
According to the last comment on this bug report you should be able to click on the console view to jump to code in CDT 7.0.
It might be worth checking out the milestone builds to see if the grouping of error messages is better. If not raising a bug to attempt to group related messages would be a good idea.
Upvotes: 1
Reputation: 8713
I suppose it's because CDT is still a bit immature and probably it can't parse g++ output in the best possible way. Line ../test.cpp: In constructor 'A::A()':
doesn't contain a line number so CDT can't place error marker in test.cpp
editor and probably this issue affects Problems view.
There are more troubles with Problems view. For example you can delete only visible errors from the view, so if you'll get more than default 100 items you have to sequentially delete it hundred by hundred. Also errors are not automatically removed after clean, if error occured inside independent header file. Just be indulgent, they are improving CDT from release to release.
Additional question - What do you mean by "to make Console view clickable"?
Upvotes: 0
Reputation: 1424
Fields get initialised in the order they are declared in the class. The compiler is helping you by telling you that the constructor is initialising then in the wrong order. This can cause strange errors, if the order of initialization matters.
Upvotes: 0
Reputation: 4921
There are multiple lines in the warning because each line refers to a different line of code. The problem being warned about is what's happening to the m_b
that's declared on line 9, it's because of the fact that m_a
on line 8 is declared before m_b
is, but it's caused by what's happening in your initializer list, which starts on line 3.
With gcc it's possible for warnings that aren't related to each other to appear one after the other (i.e., a bunch of unrelated stuff all wrong in main
), so Eclipse can't tell from the output whether those are separate warnings or all related to the same issue.
Upvotes: 6