Closed
Description
In the following example code, I have two variables int abc
that should be private to the files (internal linkage). They are in anonymous namespaces. But, they conflict with each other.
main.cc
:
import mymod;
int main() {
foo();
}
mymod.cppm
:
module;
#include <stdio.h>
export module mymod;
export import :part1;
namespace { int abc; }
export void foo() {
printf("In foo() %d\n", abc);
}
part1.cppm
:
export module mymod:part1;
namespace { int abc; }
export void part1_fun() {}
Compiler error:
mymod.cppm:9:29: error: reference to 'abc' is ambiguous
9 | printf("In foo() %d\n", abc);
| ^
/.../part1.cppm:4:17: note: candidate found by name lookup is '(anonymous namespace)::abc'
4 | namespace { int abc; }
| ^
mymod.cppm:6:17: note: candidate found by name lookup is '(anonymous namespace)::abc'
6 | namespace { int abc; }
| ^