| 
     
      
      
      From: Keith M. <kei...@us...> - 2014-11-12 09:37:31
      
     
   | 
On 11/11/14 22:56, chivin90 wrote:
> I wrote code for complex numbers using include file <Mingw /include
> /complex.h> . When I compile the file
> 
>>> gcc test.c -o test.exe
> works correctly. However, when I compile another file <fft.c> where by
>>> c ++ -o fft.c fft.exe
I presume this is a typo, and that you actually mean:
  g++ -o fft.exe fft.c
> I have the following error:
> 
> fft.c:420:23: error: ISO c++ forbids declaration of declaration of 'make_cv'
> with no type [-fpermissive] 
>    complex* make_cv(int n){
> 
> [...snip similar diagnostics...]
FWIW, this isn't peculiar to MinGW; see below...
> The source code of the function is as follows
> #ifndef complex
> #define complex _Complex
> #endif
> complex* make_cv(int n) {
>     return (complex*) malloc(sizeof (complex) * n);
> }
You should provide such examples in the SSCCE form[*]; unfortunately,
while it's close, this isn't quite complete.
[*]: http://sscce.org/
> I am using c++ (GCC 4.8.1).
After adding the two missing includes, to complete your example, I can
reproduce this with my GCC 4.8.2 mingw32-g++ cross compiler, and also
with the native (Debian 4.8.2-2) g++ on the Linux host.
I don't have a definitive answer for you -- I would probably still
choose FORTRAN for complex number crunching -- but it would seem that
C99 and C++98 complex number handling, (substantially unchanged in
C++11, AIUI), may be mutually incompatible; (IOW, if you are writing
C++, use C++ complex classes, not the C99 provisions of complex.h).  You
may get a more definitive answer, if you ask on the GCC list, or in one
of the more generalized C/C++ programming fora; if you do so, please
report any final outcome back here, just to complete this thread.
-- 
Regards,
Keith.
 |