'complex' undeclared identifier

This is a discussion on 'complex' undeclared identifier within the Windows Programming forums, part of the Platform Specific Boards category; I am writing a program using complex numbers. By #including the <complex> library in my .cpp file I can work ...

  1. #1
    Registered User
    Join Date
    Feb 2010
    Posts
    44

    'complex' undeclared identifier

    I am writing a program using complex numbers. By #including the <complex> library in my .cpp file I can work with it just fine. If I want to define a function in a header file like this:

    int Matrixmult((complex<double>)* , (complex<double>)* , (complex<double>)* );

    I get an error C2065: 'complex': undeclared identifier. I don't really understand this because I have #included the <complex> library before the header file in my .cpp file:

    #include <complex>
    #include <iostream>
    #include <fstream>
    #include <string>
    #include <functions_refl.h>

    where the last one is my header file.

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Try std::complex instead.

  3. #3
    Registered User
    Join Date
    Feb 2010
    Posts
    44
    ok, thank you, that works.

    Now I get an error C2059: syntax error: ',' though
    Code:
    int Matrixmult((std::complex<double>)* , (std::complex<double>)* , (std::complex<double>)* );
    I don't see why I can't use a comma in a function definition.

  4. #4
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,593
    That is a declaration. But first I'd try removing the ( and ): eg
    int Matrixmult(std::complex<double>*, ...);
    If that doesn't work, then post the smallest compilable snippet of code that demonstrates the problem.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  5. #5
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,717
    Get rid of those parentheses, e.g.,
    Code:
    int Matrixmult(std::complex<double>*, std::complex<double>*, std::complex<double>*);
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  6. #6
    Registered User
    Join Date
    Feb 2010
    Posts
    44
    ok, that did it I don't know why I put them there in the first place. I must say that I think the compiler's error message is not the clearest I've ever seen.

  7. #7
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,593
    The compiler was confused, just as you were. It didn't know what was wrong and so spit out an unintelligible error message.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. An error is driving me nuts!
    By ulillillia in forum C Programming
    Replies: 5
    Last Post: 04-04-2009, 09:15 PM
  2. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 01:53 AM
  3. Why wont my function exit correctly?
    By LightsOut06 in forum C Programming
    Replies: 2
    Last Post: 10-09-2005, 09:23 PM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  5. Problem with Visual C++ Object-Oriented Programming Book.
    By GameGenie in forum C++ Programming
    Replies: 9
    Last Post: 08-29-2005, 11:21 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21