-
Notifications
You must be signed in to change notification settings - Fork 13.5k
clang-cl treats different extern "C"
declarations as redeclarations
#29512
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
MSVC's model doesn't make sense. They accept this code and generate an object file with two namespace foo { extern "C" int bar = 1; }
extern "C" int bar = 2; Your code looks more like this: namespace foo { extern "C" int bar = 1; }
int bar = 2; ... which doesn't produce an invalid object with MSVC, so it's not obviously invalid. I suspect that that code is ill-formed, though. If you can make the case that there is a large body of existing code with this issue, we might find a way to accept this pattern. Otherwise my inclination is to say that this is working as intended. |
Well, this is what i get when i try to compile aspell (as you might guessed) on Windows. I can't judge which compiler is right, so feel free to close this bug if you think that clang does right thing. |
Because both declarations of
So this is definitely ill-formed, because the same variable has been declared with two different types, just as it would be if both declarations were in the same namespace. (Most of the other Note that this isn't only a problem on Windows; aspell's headers are apparently just broken when included from C++: http://stackoverflow.com/questions/25395685/aspell-wont-build-on-os-x-10-9-mavericks |
extern "C"
declarations as redeclarations
Duplicate of #95681 |
@llvm/issue-subscribers-clang-frontend Author: Gleb Popov (arrowd)
| | |
| --- | --- |
| Bugzilla Link | [29142](https://llvm.org/bz29142) |
| Version | 3.9 |
| OS | Windows NT |
| CC | @DougGregor,@zygoloid,@rnk |
Extended DescriptionThe code namespace acommon {
struct ErrorInfo;
extern "C" __declspec(dllexport) const ErrorInfo * const aerror_other;
}
extern "C" {
struct AspellErrorInfo {
const struct AspellErrorInfo * isa;
const char * mesg;
unsigned int num_parms;
const char * parms[3];
};
typedef struct AspellErrorInfo AspellErrorInfo;
extern const struct AspellErrorInfo * const aerror_other;
}
int main()
{
return 0;
} compiles with
|
Extended Description
The code
compiles with
cl.exe
, but fails withclang-cl.exe
:The text was updated successfully, but these errors were encountered: