News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

Code completion don't work perfectly in the latest version?

Started by c2q1989, February 15, 2013, 08:33:09 AM

Previous topic - Next topic

c2q1989

Version: 12.11 (windows)
OS: Windows 8 x64

    I found C::B Editor cannot provide code-assist showing members when typing symbols like dot(.), arrow(->).

    For example, supposing that I have defined "vector<double> vec;". If I wanna use vec.begin() or vec.size(), I must complete the latter part by myself, i.e. begin() or size(). No code-assist is provided.

    I am not sure whether this could be a bug? Expecting your answer. Thanks!

oBFusCATed

Please provide an example which reproduces the problem. It works for me.
But keep in mind that parsing templates and macro-expansions is not fully implemented.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

c2q1989

I just began to learn C++ a few days ago. I find this problem occured when parsing templates.

I wonder why the bug haven't been fixed yet? No offense, but it seems to be strange. Other C++ IDE, like C-Free, could do this kind of job.

ollydbg

Quote from: c2q1989 on February 16, 2013, 07:14:11 AM
I just began to learn C++ a few days ago. I find this problem occured when parsing templates.

I wonder why the bug haven't been fixed yet? No offense, but it seems to be strange. Other C++ IDE, like C-Free, could do this kind of job.
1, did you see this message:
Quote from: oBFusCATed on February 15, 2013, 08:48:47 AM
Please provide an example which reproduces the problem. It works for me.
Tell us the exact problem you have.

2, Parsing C++ is not easy, especially the the code contains templates. (search the forum, there are many topics about this issue)
Currently, no c::b devs have the time or ability to implement this, although you can help c::b by supplying patches. :)
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

c2q1989

This example comes from Accelerated C++. I have underlined the problematic parts.

#include <algorithm>
#include <iomanip>
#include <ios>
#include <stdexcept>
#include <string>
#include <vector>
#include "grade.h"
#include "Student_info.h"

using std::cin;                          using std::setprecision;
using std::cout;                        using std::sort;
using std::domain_error;             using std::streamsize;
using std::endl;                         using std::string;
using std::max;                         using std::vector;

int main()
{
    vector<Student_info> students;
    Student_info record;
    string::size_type maxlen = 0;

    while (read(cin, record))
    {
        maxlen = max(maxlen, record.name.size());
        students.push_back(record);
    }

    // alphabetize the student records
    sort(students.begin(), students.end(), compare);

    // write the name and grades
    for (vector<Student_info>::size_type i = 0;
        i != students.size(); ++i)
    {
        // write the name, padded on the right to maxlen + 1 characters
        cout << students.name
             << string(maxlen + 1 - students.name.size(), ' ');
        // compute and write the grade
        try {
            double final_grade = grade(students);
            streamsize prec = cout.precision();
            cout << setprecision(3) << final_grade
                 << setprecision(prec);
        } catch (domain_error e) {
            cout << e.what();
        }
        cout << endl;
    }
    return 0;
}

oBFusCATed

Please use code tags, next time and also have you tried to use "using namespace" or "std::" with the special "using blabla" directives?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

c2q1989

Thanks for your help! ;) The problem has been solved by using namespace.

But I still hope that C::B could fully support "using std::blabla".

oBFusCATed

Quote from: c2q1989 on February 20, 2013, 07:15:03 AM
But I still hope that C::B could fully support "using std::blabla".
Me, too.

ollydbg: Can you look at this problem?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

ollydbg

Quote from: oBFusCATed on February 20, 2013, 09:50:29 AM
Quote from: c2q1989 on February 20, 2013, 07:15:03 AM
But I still hope that C::B could fully support "using std::blabla".
Me, too.

ollydbg: Can you look at this problem?
It is a problem, should take time to solve, all those kind of c++ template related bug are hard to solve.
I mainly focus on other important parts of CC, e.g. code-completion testing frame work. :)
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

oBFusCATed

I don't think it is template related bug, but namespace related and currently we handle namespaces pretty bad.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

ollydbg

Quote from: oBFusCATed on February 20, 2013, 03:03:32 PM
I don't think it is template related bug, but namespace related and currently we handle namespaces pretty bad.
Ok, you're right, the namespace related bug, this is another dirty part of the CC. It's all about the scope/symbol/type resolution, but our parser does not have the power of a c++ compiler. :)
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

c2q1989

Quote from: oBFusCATed on February 20, 2013, 09:50:29 AM
Quote from: c2q1989 on February 20, 2013, 07:15:03 AM
But I still hope that C::B could fully support "using std::blabla".
Me, too.

ollydbg: Can you look at this problem?

;D You guys are extremely nice! Hoping that I could be one member of your group someday.

ollydbg

Quote from: c2q1989 on February 22, 2013, 06:26:39 AM
...
;D You guys are extremely nice! Hoping that I could be one member of your group someday.
Thanks for the encouragement.

If you really consider to become a C::B developer, you can start by supplying patches to fix bugs/add new features. (You need to try build C::B, and debug it)
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.