The Student Room Group

Where to get C header files (complex.h)?

Hi,

I'm relatively new to C, and I need this header file, do you know where I can find it?

I'm running some C code through another program so I'm not using Visual Studio or anything to run my code, although my uni does have Visual Studio. A 'complex' file exists in the Visual Studio directory but it has no extension, so I assume it is some other type of file to do with C++ perhaps..

Thanks,
Lee
There are two incompatible complex number systems.

<complex> is the C++ template based complex number header file - it requires a C++ compiler and should be part of the MSVC C++ standard includes .

<complex.h> is the C99 facility that adds support for _Complex. It requires a C99 (
ISO/IEC 9899:1999)
compliant C compiler (but I don't think MS know how to make one).
I'm running some C code through another program

What is this other program? From briefly flicking through what the standard actually requires of complex.h, it doesn't look like something which can be implemented in the header alone: it requires compiler support for the underlying type. Of course it's still possible to use an alternative library providing for complex arithmetic, but unless this 'other program' supports at least some of C99, you're not just going to be able to use a copy of the standard header.

EDIT: Which is actually what maturestudy said, just in more words.
(edited 12 years ago)
Reply 3
Original post by TheUnbeliever
What is this other program? From briefly flicking through what the standard actually requires of complex.h, it doesn't look like something which can be implemented in the header alone: it requires compiler support for the underlying type. Of course it's still possible to use an alternative library providing for complex arithmetic, but unless this 'other program' supports at least some of C99, you're not just going to be able to use a copy of the standard header.

EDIT: Which is actually what maturestudy said, just in more words.


Original post by maturestudy
There are two incompatible complex number systems.

<complex> is the C++ template based complex number header file - it requires a C++ compiler and should be part of the MSVC C++ standard includes .

<complex.h> is the C99 facility that adds support for _Complex. It requires a C99 (
ISO/IEC 9899:1999)
compliant C compiler (but I don't think MS know how to make one).


The other program is Fluent, computational fluid dynamics software by Ansys Inc. I'm assuming it supports C99 (I've tried to find out but to no avail) so I should be fine. But it I just need complex.h so I can try it, seeing as I can't find out if it uses C99 or whatnot.
Original post by LeeC
The other program is Fluent, computational fluid dynamics software by Ansys Inc. I'm assuming it supports C99 (I've tried to find out but to no avail) so I should be fine. But it I just need complex.h so I can try it, seeing as I can't find out if it uses C99 or whatnot.


It looks to me like ANSYS FLUENT uses the system compiler, which is likely to be MSVC if you're on Windows. MSVC is not C99-compliant and likely never will be.

In any case, there's absolutely no guarantee that you could take a complex.h header intended to be used with one toolchain and use it with another. Because it relies on compiler support, it's likely to rely on implementation-specific names. e.g. For example, see "#ifdef __GNUC__" in this OpenBSD copy.
(edited 12 years ago)
Reply 5
Original post by TheUnbeliever
It looks to me like ANSYS FLUENT uses the system compiler, which is likely to be MSVC if you're on Windows. MSVC is not C99-compliant and likely never will be.

In any case, there's absolutely no guarantee that you could take a complex.h header intended to be used with one toolchain and use it with another. Because it relies on compiler support, it's likely to rely on implementation-specific names. e.g. For example, see "#ifdef __GNUC__" in this OpenBSD copy.


Ok, I'm quickly getting out of my depth here. In fluent you can use Complied or Interpreted code for UDFs (user defined functions), at the moment I'm using an interpreted UDF, does this change the likelihood of this working or not?
To move in a more useful direction: it is possible to set up alternative toolchains like GCC or Clang under Windows. It's not a two-second exercise, but it may still be quicker than rewriting to use an external library if your code isn't tiny. You will probably need to crib together your own makefile from the ones provided with FLUENT if you took this route.

Original post by LeeC
Ok, I'm quickly getting out of my depth here. In fluent you can use Complied or Interpreted code for UDFs (user defined functions), at the moment I'm using an interpreted UDF, does this change the likelihood of this working or not?


Nope, sorry. See this page - the interpreter compiles something which looks like but isn't actually standard C.
(edited 12 years ago)
Reply 7
Original post by TheUnbeliever
To move in a more useful direction: it is possible to set up alternative toolchains like GCC or Clang under Windows. It's not a two-second exercise, but it may still be quicker than rewriting to use an external library if your code isn't tiny. You will probably need to crib together your own makefile from the ones provided with FLUENT if you took this route.



Nope, sorry. See this page - the interpreter compiles something which looks like but isn't actually standard C.


Well thanks A LOT for your help, I haven't fully understood all of what you have said but at least I understand that this isn't going to be a trivial thing. Also I'm using this on Uni computers and don't have access to a lot of the folders I need to anyway which is a bummer.

It's possible to code in Fortran then 'link' it or something like that so that the complier understands it, I will go into that route seeing as I have the code in Fortran anyway.

Quick Reply

Latest

Trending

Trending