unknown type name __thiscall

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

unknown type name __thiscall

Stephen Deken
Hello list,

I'm getting strange errors emitted by clang++ on Windows 7 (built
using Visual Studio 9 from trunk) when attempting to compile C++ code
that includes the VC9 headers:

cfetest.cpp:

        #include <iostream>
        using namespace std;
        int main( int, char** ) {
                cout <<"hello world!" <<endl;
                return 0;
        }

This emits 122 errors.  Some are about __thiscall, which clang/clang++
apparently doesn't define, others are related to MS-specific
extensions such as __is_base_of, or improper typedefs within
templates, or delete[]ing void pointers, etc.

Basically, it's rubbish :)

I didn't expect it to be able to emit code (I'm only really interested
in the semantic analysis), but I can't do that if the system headers
barf errors all over the place.  Am I doing something wrong with my
setup, or is it expected that trying to use Visual Studio's C++
headers is a Bad Idea?

Thanks,

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

Re: unknown type name __thiscall

Douglas Gregor

On Mar 16, 2010, at 2:28 PM, Stephen Deken wrote:

> Hello list,
>
> I'm getting strange errors emitted by clang++ on Windows 7 (built
> using Visual Studio 9 from trunk) when attempting to compile C++ code
> that includes the VC9 headers:
>
> cfetest.cpp:
>
> #include <iostream>
> using namespace std;
> int main( int, char** ) {
> cout <<"hello world!" <<endl;
> return 0;
> }
>
> This emits 122 errors.  Some are about __thiscall, which clang/clang++
> apparently doesn't define,

No, we don't define that. We could (and probably should).

> others are related to MS-specific
> extensions such as __is_base_of

These are also extension that we could probably support under -fms-extensions. I, personally, don't have strong motivation to implement them, but of course we'll be happy to review patches.

> , or improper typedefs within
> templates, or delete[]ing void pointers, etc.
>
> Basically, it's rubbish :)

Visual C++ accepts a lot of ill-formed code, especially in templates. Teaching Clang's parser to work around those problems will be a trying experience. For reference, the author of GCC-XML dealt with this problem with GCC by patching the headers. It might be worthwhile to see what he had to do:

        http://www.gccxml.org/HTML/Index.html

> I didn't expect it to be able to emit code (I'm only really interested
> in the semantic analysis), but I can't do that if the system headers
> barf errors all over the place.  Am I doing something wrong with my
> setup, or is it expected that trying to use Visual Studio's C++
> headers is a Bad Idea?


I've never tried it, but I do know that the headers Microsoft ships are far from well-formed C++, so this is probably the expected behavior given that Clang is a picky compiler when it comes to standards conformance.

        - 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: unknown type name __thiscall

Anton Korobeynikov
In reply to this post by Stephen Deken
Hello

> I didn't expect it to be able to emit code (I'm only really interested
> in the semantic analysis), but I can't do that if the system headers
> barf errors all over the place.  Am I doing something wrong with my
> setup, or is it expected that trying to use Visual Studio's C++
> headers is a Bad Idea?
I think you already answered your own question with:

> others are related to MS-specific
> extensions such as __is_base_of, or improper typedefs within
> templates, or delete[]ing void pointers, etc.

--
With best regards, Anton Korobeynikov
Faculty of Mathematics and Mechanics, Saint Petersburg State University

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

Re: unknown type name __thiscall

Stefan Seefeld
In reply to this post by Douglas Gregor
On 03/16/2010 05:48 PM, Douglas Gregor wrote:

> On Mar 16, 2010, at 2:28 PM, Stephen Deken wrote:
>
>    
>> Hello list,
>>
>> I'm getting strange errors emitted by clang++ on Windows 7 (built
>> using Visual Studio 9 from trunk) when attempting to compile C++ code
>> that includes the VC9 headers:
>>
>> cfetest.cpp:
>>
>> #include<iostream>
>> using namespace std;
>> int main( int, char** ) {
>> cout<<"hello world!"<<endl;
>> return 0;
>> }
>>
>> This emits 122 errors.  Some are about __thiscall, which clang/clang++
>> apparently doesn't define,
>>      
> No, we don't define that. We could (and probably should).
>    

Pardon me for jumping in here, but this brings up a high-level design
question I have:

With the Synopsis parsers I used the approach of emulating external
(real) compilers, by scanning for them, and using heuristics to figure
out what symbols they would expect and emit, as well as where they store
system headers.

Thus, my parser wouldn't need to do any of this.

How does this work with CLang ? Does it know anything about specific
platforms ? What do I need to feed in to get an environment similar to,
say, GCC ?

Thanks,
         Stefan



--

       ...ich hab' noch einen Koffer in Berlin...

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

Re: unknown type name __thiscall

Douglas Gregor

On Mar 16, 2010, at 3:54 PM, Stefan Seefeld wrote:

> On 03/16/2010 05:48 PM, Douglas Gregor wrote:
>> On Mar 16, 2010, at 2:28 PM, Stephen Deken wrote:
>>
>>
>>> Hello list,
>>>
>>> I'm getting strange errors emitted by clang++ on Windows 7 (built
>>> using Visual Studio 9 from trunk) when attempting to compile C++ code
>>> that includes the VC9 headers:
>>>
>>> cfetest.cpp:
>>>
>>> #include<iostream>
>>> using namespace std;
>>> int main( int, char** ) {
>>> cout<<"hello world!"<<endl;
>>> return 0;
>>> }
>>>
>>> This emits 122 errors.  Some are about __thiscall, which clang/clang++
>>> apparently doesn't define,
>>>
>> No, we don't define that. We could (and probably should).
>>
>
> Pardon me for jumping in here, but this brings up a high-level design
> question I have:
>
> With the Synopsis parsers I used the approach of emulating external
> (real) compilers, by scanning for them, and using heuristics to figure
> out what symbols they would expect and emit, as well as where they store
> system headers.
>
> Thus, my parser wouldn't need to do any of this.
>
> How does this work with CLang ? Does it know anything about specific
> platforms ? What do I need to feed in to get an environment similar to,
> say, GCC ?


Clang does know about specific compilers, platforms, targets, and system headers. It does not scan for them at all.

For specific compilers, there are extension flags, e.g., -fms-extensions (Visual C++), -std=gnu99 (C99 w/ GNU extensions), etc. These are stored in LangOptions and are used for keywords, parsing, semantic analysis, etc.

For specific platforms and targets, we have TargetInfo.

For header search paths, we have InitHeaderSearch.cpp, which is a mess based on the target triple.

IMO, only the last of those is really amenable to scanning the system compiler, although I guess we could have some kind of top-level flag to "emulate compiler Foo as best you can".

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