Skip to content

clang-cl should be compatible to cl.exe regarding extern "C" handling in namespaces #24569

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

Closed
gjasny mannequin opened this issue Jul 21, 2015 · 4 comments
Closed

clang-cl should be compatible to cl.exe regarding extern "C" handling in namespaces #24569

gjasny mannequin opened this issue Jul 21, 2015 · 4 comments
Labels
bugzilla Issues migrated from bugzilla c++ clang:frontend Language frontend issues, e.g. anything involving "Sema" duplicate Resolved as duplicate platform:windows

Comments

@gjasny
Copy link
Mannequin

gjasny mannequin commented Jul 21, 2015

Bugzilla Link 24195
Version trunk
OS All
Blocks #14079
CC @XVilka,@DougGregor,@rnk

Extended Description

Hello,

I try to use libclang to parse some source files. But the error is also visible in clang-cl (r242653 nightly build).

The error originates from boost interprocess headers which declare windows.h functions different than windows.h. The error got a work-around in later boost versions but unfortunately we are stuck with 1.50 for a while.

It boils down to Visual Studio Compiler accepting the following, but clang-cl does not:

extern "C" void foo(int a);
 
namespace bar {
    extern "C" void foo(long b);
}

In the boost case the functions get pointers to different structures.

Could you modify clang to accept this oddity with enabled ms-extensions / ms-compatibility like cl.exe does?

Thanks,
Gregor

@rnk
Copy link
Collaborator

rnk commented Jul 21, 2015

This does fall under the general category of things we can do for compatibility.

We can probably pattern match this case in the decl merging machinery. Today we say they have different types, but the user code would probably be fine if we just ignored the second declaration with a warning.

@llvmbot
Copy link
Member

llvmbot commented Oct 24, 2017

[...]
The error originates from boost interprocess headers which declare windows.h
functions different than windows.h. The error got a work-around in later
boost versions but unfortunately we are stuck with 1.50 for a while.

Aside, I assume that workaround in boost is the introduction of BOOST_USE_WINDOWS_H which, when defined, includes the real windows.h header instead of the extern "C" equivalents declared in a boost namespace.

This is however not always acceptable or a viable option when using clang-cl on an existing code base using boost, as this suddenly exposes all the windows.h preprocessor nasties to the complete code base. This can result in a huge fallout.

If this could be resolved under the hood of ms-extensions/ms-compatibility that would be a much better situation.

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
@Endilll Endilll changed the title clang-cl should be compatible to cl.exe regarding extern C handling in namespaces clang-cl should be compatible to cl.exe regarding extern "C" handling in namespaces Jul 25, 2024
@Endilll Endilll added platform:windows clang:to-be-triaged Should not be used for new issues labels Jul 25, 2024
@AaronBallman AaronBallman added duplicate Resolved as duplicate and removed clang:to-be-triaged Should not be used for new issues labels Jul 26, 2024
@AaronBallman
Copy link
Collaborator

Duplicate of #95681

@AaronBallman AaronBallman marked this as a duplicate of #95681 Jul 26, 2024
@AaronBallman AaronBallman closed this as not planned Won't fix, can't repro, duplicate, stale Jul 26, 2024
@EugeneZelenko EugeneZelenko added the clang:frontend Language frontend issues, e.g. anything involving "Sema" label Jul 26, 2024
@llvmbot
Copy link
Member

llvmbot commented Jul 26, 2024

@llvm/issue-subscribers-clang-frontend

Author: None (24bb07d4-a064-4a64-856b-dc3103e7a3ac)

| | | | --- | --- | | Bugzilla Link | [24195](https://llvm.org/bz24195) | | Version | trunk | | OS | All | | Blocks | llvm/llvm-project#14079 | | CC | @XVilka,@DougGregor,@rnk |

Extended Description

Hello,

I try to use libclang to parse some source files. But the error is also visible in clang-cl (r242653 nightly build).

The error originates from boost interprocess headers which declare windows.h functions different than windows.h. The error got a work-around in later boost versions but unfortunately we are stuck with 1.50 for a while.

It boils down to Visual Studio Compiler accepting the following, but clang-cl does not:

extern "C" void foo(int a);
 
namespace bar {
    extern "C" void foo(long b);
}

In the boost case the functions get pointers to different structures.

Could you modify clang to accept this oddity with enabled ms-extensions / ms-compatibility like cl.exe does?

Thanks,
Gregor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla c++ clang:frontend Language frontend issues, e.g. anything involving "Sema" duplicate Resolved as duplicate platform:windows
Projects
None yet
Development

No branches or pull requests

5 participants