complex.h in Visual Studio 2008

This is a discussion on complex.h in Visual Studio 2008 within the C Programming forums, part of the General Programming Boards category; So I wrote a SVD code in C - at first I used Dev-C++ which (correct me if I'm wrong) ...

  1. #1
    Registered User
    Join Date
    Oct 2010
    Posts
    3

    complex.h in Visual Studio 2008

    So I wrote a SVD code in C - at first I used Dev-C++ which (correct me if I'm wrong) came with a different compiler (mingw or something?) from the one used in Microsoft Visual Studio 2008. I am using complex.h a lot in my SVD code and it worked perfectly with Dev-C++.
    But in order to use the SVD code in Embedded Matlab I installed Visual Studio to use its compiler and learned that it doesn't have/support C99 so I can't use complex.h

    Is there a workaround to this without having to re-write my whole SVD code (which is really long), other than writing my own "complex.h" header file and all the functions associated with the operations I'm doing (complex number multiplication, addition, magnitude, etc.)?

    Thanks!

  2. #2
    Registered User claudiu's Avatar
    Join Date
    Feb 2010
    Location
    London, United Kingdom
    Posts
    2,094
    So why don't you compile it with a compiler that supports the C standard?
    1. Get rid of gets(). Never ever ever use it again. Replace it with fgets() and use that instead.
    2. Get rid of void main and replace it with int main(void) and return 0 at the end of the function.
    3. Get rid of conio.h and other antiquated DOS crap headers.
    4. Don't cast the return value of malloc, even if you always always always make sure that stdlib.h is included.

  3. #3
    Registered User
    Join Date
    Oct 2010
    Posts
    3
    Do you happen to know any compilers that are supported in Matlab R2009a? My advisor had suggested that I use Visual Studio so I just went with that...
    Sorry I'm pretty new at this. =/

  4. #4
    Registered User claudiu's Avatar
    Join Date
    Feb 2010
    Location
    London, United Kingdom
    Posts
    2,094
    Well, I don't know much about Matlab and C/C++ integration but here is what I found out:

    If you go here: Support - Supported / Compatible Compilers - Release 2009a

    you will get all the Matlab compatible compilers.

    And if you go here:

    IntelĀ® Compilers - Intel® Software Network

    and read about the Intel C++ compiler, it looks like it is compatible with ANSI C 90, so it may be worth giving it a try. However, it is not free and I am not sure whether you can just work with a trial version or something.


    EDIT: Nevermind, forgot <complex.h> is a C99 thing.
    Last edited by claudiu; 10-05-2010 at 03:52 PM.
    1. Get rid of gets(). Never ever ever use it again. Replace it with fgets() and use that instead.
    2. Get rid of void main and replace it with int main(void) and return 0 at the end of the function.
    3. Get rid of conio.h and other antiquated DOS crap headers.
    4. Don't cast the return value of malloc, even if you always always always make sure that stdlib.h is included.

  5. #5
    Registered User
    Join Date
    Oct 2010
    Posts
    3
    Yeah, I actually saw the list of supported compilers in Matlab, too. Intel C++ supports C99 "partially" but I think it should be okay for what I'm doing.
    C99 - Wikipedia, the free encyclopedia

    Pelles C is another option which isn't on the Matlab supported-compilers list but I just downloaded an installation file which apparently allows you to use the compiler in Matlab: MATLAB Central - File detail - Mexopts for Pelles C

    Gotta try these out - fingers crossed.
    The only issue I can think of is that I'm not going to be the end-user so it "should" work on other computers too - not just my own. I'd have to put in a note saying "use ___ specific compiler"

  6. #6
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,411
    Quote Originally Posted by claudiu View Post
    and read about the Intel C++ compiler, it looks like it is compatible with ANSI C 90, so it may be worth giving it a try. However, it is not free and I am not sure whether you can just work with a trial version or something.[/COLOR]
    There is no ANSI C90 standard.
    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.

  7. #7
    Registered User claudiu's Avatar
    Join Date
    Feb 2010
    Location
    London, United Kingdom
    Posts
    2,094
    Quote Originally Posted by Elysia View Post
    There is no ANSI C90 standard.
    Right, well I was refering to the C90 version which contains some minor changes to C89. It's not a standard per say.
    1. Get rid of gets(). Never ever ever use it again. Replace it with fgets() and use that instead.
    2. Get rid of void main and replace it with int main(void) and return 0 at the end of the function.
    3. Get rid of conio.h and other antiquated DOS crap headers.
    4. Don't cast the return value of malloc, even if you always always always make sure that stdlib.h is included.

  8. #8
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,411
    There is an ISO C90 standard. But there is no ANSI C90 standard.
    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. LDAP Query
    By Travoiz in forum C++ Programming
    Replies: 0
    Last Post: 08-13-2009, 02:58 PM
  2. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 04:45 PM
  3. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM
  4. load gif into program
    By willc0de4food in forum Windows Programming
    Replies: 14
    Last Post: 01-11-2006, 09:43 AM
  5. Learning OpenGL
    By HQSneaker in forum C++ Programming
    Replies: 7
    Last Post: 08-06-2004, 08:57 AM

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