C++ problem under MAC. Please help!

Discussion in 'Mac Programming' started by forfan, Nov 22, 2007.

  1. macrumors newbie

    Nov 20, 2007
    I am not sure whether it is a MAC problem or not.
    I am new to mac programming.

    Recently I am trying to learn program with MTL4(http://www.osl.iu.edu/research/mtl/mtl4/doc/manual.php3).

    Here is a sample program copied from MTL document. It is a very simple program which implements a complex vector and prints it out by using MTL.
    // File: vector2.cpp
    #include <complex>
    #include <iostream>
    #include <boost/numeric/mtl/mtl.hpp>
    int main(int argc, char* argv[])
        using namespace mtl;
        // Define dense vector of complex with 7 elements.
        dense_vector<std::complex<float>, vector::parameters<tag::row_major> >  v(7);
        // Set all elements to 3+2i
        v= std::complex<float>(3.0, 2.0);
        std::cout << "v is " << v << "\n";
        // Set all elements to 5+0i
        v= 5.0;
        std::cout << "v is " << v << "\n";
        v= 6;
        std::cout << "v is " << v << "\n";
        return 0;
    I tried to compile it under terminal, and got the following error:
    why the compiler can't do a auto conversion for me?

    My OS is Leopard,
    g++ version:
    i686-apple-darwin9-g++-4.0.1 (GCC) 4.0.1 (Apple Inc. build 5465)

    any advise?

    thx in advance.
  2. macrumors 6502a

    Jul 15, 2003
    Man back in the day when i programmed, int main passed no arguments.
    It actually looks like you're assigning values incorrectly. As all your errors are on assignment lines.
  3. macrumors 6502a

    Jul 15, 2003
    It also helps to try and describe what the code is trying to do.
  4. thread starter macrumors newbie

    Nov 20, 2007
    Sorry, it is not the right place to post my question

    I have tested the program under my linux box, and got same error messages.

    It is not a Mac programming problem, but I still need help.
    Can anybody help for that?
  5. thread starter macrumors newbie

    Nov 20, 2007
    Thank you for the replies

    the program uses MTL to construct a complex vector with size 7.

    v = n means assigning n to every element of vector.

    I know it is an assignment error.

    The problem is why it fails. I thank MTL vector class should have a good assignment implementation.

    maybe there is something wrong with my compile command.

    I have totally no idea with the error.
  6. macrumors 6502a

    Jul 15, 2003
    I don't think you need the extra > when you create your dense vector. It has no opening < which means it's probably treating it as a conditional statement.
  7. thread starter macrumors newbie

    Nov 20, 2007
    this line?
    dense_vector<std::complex<float>, vector::parameters<tag::row_major> > v(7);

    there are 3 "<" and three ">", one for dense_vector, one for complex and one for vector::parameters.
    I don't think it is a problem.

    I tried to remove the last > and got a "lose > " error.
  8. thread starter macrumors newbie

    Nov 20, 2007
    problem solved

    I made a stupid spelling error in code input:
    dense_vector<std::complex<float>, vector::parameters<tag::row_major> > v(7);
    I input the code "v[7]" but not "v(7)".
    Very stupid.

    Sorry for that.

Share This Page