Skip to content

#pragma once causes compile failures when used with includes in global module fragment #59708

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
davidstone opened this issue Dec 26, 2022 · 2 comments
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" duplicate Resolved as duplicate

Comments

@davidstone
Copy link
Contributor

davidstone commented Dec 26, 2022

Attempting to compile the following valid set of source files

// a.hpp
#pragma once
using a = int;
// b.hpp
#pragma once
#include "a.hpp"
a b;
// c.cpp
module;
#include "b.hpp"
export module c;

Causes Clang to error with

In file included from c.cpp:3:
b.hpp:4:1: error: unknown type name 'a'
a b;
^

Changing from #pragma once to #ifdnef FOO...-style include-guards causes the code to compile as expected. It appears as though #pragma once is applied to the set of all headers that have that pragma collectively?

@davidstone davidstone changed the title #pragma once applies to all headers in global module fragment #pragma once causes compile failures when used with includes in global module fragment Dec 26, 2022
@EugeneZelenko EugeneZelenko added clang:frontend Language frontend issues, e.g. anything involving "Sema" and removed new issue labels Dec 27, 2022
@llvmbot
Copy link
Member

llvmbot commented Dec 27, 2022

@llvm/issue-subscribers-clang-frontend

@davidstone
Copy link
Contributor Author

Duplicate of #58532

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

No branches or pull requests

3 participants