clang compiling complex reports err

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

clang compiling complex reports err

way_lzl

If I use MSVC's math.h, clang will report err I have formed a simple case to show it:

 

struct _complex {
        double x,y;
        } ;

 

#if SHOWERR
void foo( struct _complex _Complex) {
 _Complex.x = 0;
}
#else
void foo( struct _complex cc) { 
 cc.x = 0;
}
#endif


int main()
{
 struct _complex cc;
 foo(cc);
}

 

clang aa.cpp -DSHOWERR=1

aa.cpp(7) :  error: '_Complex struct' is invalid
void foo( struct _complex _Complex) {
                          ^

 

It seems _Complex is a reserved key word. Any suggestion?

 

Thanks

--------------------------------
--Zhanglin


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: clang compiling complex reports err

Francois Pichet


2011/1/4 <[hidden email]>

If I use MSVC's math.h, clang will report err I have formed a simple case to show it:

 

struct _complex {
        double x,y;
        } ;

 

#if SHOWERR
void foo( struct _complex _Complex) {
 _Complex.x = 0;
}
#else
void foo( struct _complex cc) { 
 cc.x = 0;
}
#endif


int main()
{
 struct _complex cc;
 foo(cc);
}

 

clang aa.cpp -DSHOWERR=1

aa.cpp(7) :  error: '_Complex struct' is invalid
void foo( struct _complex _Complex) {
                          ^

 

It seems _Complex is a reserved key word. Any suggestion?


 
yes clang considers _Complex to be a reserved keyword, MSVC don't. But _Complex  is not in MSVC headers, it is in your cod right?
So you can rename that variable. Otherwise feel free to submit a PR or a patch.

We had the same problem with the _Bool keyword.


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: clang compiling complex reports err

way_lzl
In reply to this post by way_lzl

No, _Complex is used in MSVC's math.h.

line 135: _CRTIMP double  __cdecl _cabs(__in struct _complex _Complex);

 

Then if I use math.h with Clang on windows, what should I do?

 

------------------------------------------------
--Zhanglin
----- Original Message -----
From: Francois Pichet <[hidden email]>
To: [hidden email]
Subject: Re: [cfe-dev] clang compiling complex reports err
Date: 2011-1-4 16:46:49



2011/1/4 <[hidden email]>

If I use MSVC's math.h, clang will report err I have formed a simple case to show it:

struct _complex {
double x,y;
} ;

#if SHOWERR
void foo( struct _complex _Complex) {
_Complex.x = 0;
}
#else
void foo( struct _complex cc) {
cc.x = 0;
}
#endif


int main()
{
struct _complex cc;
foo(cc);
}

clang aa.cpp -DSHOWERR=1

aa.cpp(7) : error: '_Complex struct' is invalid
void foo( struct _complex _Complex) {
^

It seems _Complex is a reserved key word. Any suggestion?


yes clang considers _Complex to be a reserved keyword, MSVC don't. But _Complex is not in MSVC headers, it is in your cod right?
So you can rename that variable. Otherwise feel free to submit a PR or a patch.

We had the same problem with the _Bool keyword.


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: clang compiling complex reports err

Francois Pichet


2011/1/4 <[hidden email]>

No, _Complex is used in MSVC's math.h.

line 135: _CRTIMP double  __cdecl _cabs(__in struct _complex _Complex);

Ok that's in Visual Studio 2005. It was changed in MSVC 2008 to not use _Complex as parameter name.
  

Then if I use math.h with Clang on windows, what should I do?

Either you submit a patch to fix it yourself or you can submit a PR and wait for someone else to fix it.
Otherwise use VS 2008.


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: clang compiling complex reports err

John McCall
On Jan 4, 2011, at 1:44 AM, Francois Pichet wrote:
2011/1/4 <[hidden email]>

No, _Complex is used in MSVC's math.h.

line 135: _CRTIMP double  __cdecl _cabs(__in struct _complex _Complex);


Ok that's in Visual Studio 2005. It was changed in MSVC 2008 to not use _Complex as parameter name.
  

Then if I use math.h with Clang on windows, what should I do?

Either you submit a patch to fix it yourself or you can submit a PR and wait for someone else to fix it.
Otherwise use VS 2008.

_Complex should really be a C99-only keyword.  If we did that, then you could compile as C89 without a problem.

John.

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: clang compiling complex reports err

Douglas Gregor

On Jan 4, 2011, at 5:08 PM, John McCall wrote:

On Jan 4, 2011, at 1:44 AM, Francois Pichet wrote:
2011/1/4 <[hidden email]>

No, _Complex is used in MSVC's math.h.

line 135: _CRTIMP double  __cdecl _cabs(__in struct _complex _Complex);


Ok that's in Visual Studio 2005. It was changed in MSVC 2008 to not use _Complex as parameter name.
  

Then if I use math.h with Clang on windows, what should I do?

Either you submit a patch to fix it yourself or you can submit a PR and wait for someone else to fix it.
Otherwise use VS 2008.

_Complex should really be a C99-only keyword.  If we did that, then you could compile as C89 without a problem.

GCC accepts _Complex as a keyword in C++ mode. We could turn that off in Microsoft C++ mode, of course.

- Doug


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: clang compiling complex reports err

John McCall

On Jan 4, 2011, at 5:21 PM, Douglas Gregor wrote:


On Jan 4, 2011, at 5:08 PM, John McCall wrote:

On Jan 4, 2011, at 1:44 AM, Francois Pichet wrote:
2011/1/4 <[hidden email]>

No, _Complex is used in MSVC's math.h.

line 135: _CRTIMP double  __cdecl _cabs(__in struct _complex _Complex);


Ok that's in Visual Studio 2005. It was changed in MSVC 2008 to not use _Complex as parameter name.
  

Then if I use math.h with Clang on windows, what should I do?

Either you submit a patch to fix it yourself or you can submit a PR and wait for someone else to fix it.
Otherwise use VS 2008.

_Complex should really be a C99-only keyword.  If we did that, then you could compile as C89 without a problem.

GCC accepts _Complex as a keyword in C++ mode. We could turn that off in Microsoft C++ mode, of course.

I meant C99 as "not in C89", because IIRC complex numbers were added in C99;  but it looks like GCC treats _Complex as a keyword even in -std=c89, and it's probably best to emulate that.

It definitely sounds like _Complex shouldn't be a keyword in VS2005 mode.

John.

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev