[cfe-dev] Clang Modules: modularization of standard headers required?

Dmitry Panin via cfe-dev cfe-dev at lists.llvm.org
Fri Jun 30 22:23:58 PDT 2017


I am trying to enable Clang Modules using latest version of clang on a tiny
example, but getting the following error:

error: 'std::vector' has different definitions in different modules

1) Documentation from http://clang.llvm.org/doc
s/Modules.html#modularizing-a-platform says

>> To get any benefit out of modules, one needs to introduce module maps
for software libraries starting at the bottom of the stack.

Does it mean that modularization of system/std headers is **required**
before going upper levels?
I am not using modulemaps on standard headers and would like to avoid that
for now.

2) When I try some older version of clang (say from April 2017) it doesn't
show this error on the same input. Does it mean there was regression
happened in between? Or the current behavior is actually expected?


Below comes more details and reproduction.
Full message:

In file included from main.cpp:1:
In file included from /usr/lib/gcc/x86_64-redhat-lin
ux/4.8.5/../../../../include/c++/4.8.5/vector:64:
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/
c++/4.8.5/bits/stl_vector.h:210:11: error: 'std::vector' has different
definitions in
      different modules; defined here
    class vector : protected _Vector_base<_Tp, _Alloc>
          ^
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/
c++/4.8.5/bits/stl_vector.h:210:11: note: definition in module
'experimental_Range_h' is here
    class vector : protected _Vector_base<_Tp, _Alloc>
          ^
1 error generated.


The files I am using:
// -- main.cpp:
#include <vector>
#include "Range.h"

int main () {
  return 0;
}

// -- Range.h:
#pragma once

#include <string>
#include "Bits.h"
#include <vector>

// -- Bit.h:
#pragma once
#include <iterator>

// -- module.modulemap:
module experimental_Bits_h {
   header "Bits.h"
   export *
}

module experimental_Range_h {
   header "Range.h"
   export *
}

Commandline:
$ clang++ --std=c++14 -I .  -fmodules -fcxx-modules
-fmodules-cache-path=./modules_out/_module_cache -c main.cpp -o main.o


$ clang++ --version
clang version 5.0.0 (http://llvm.org/git/clang.git
742c4c842393005d91a6f805f665b077014d061a) (http://llvm.org/git/llvm.git
a98fd55665d422389d69d94efe631fac93d11173)

-- 
Thanks,
Dmitry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170630/c11fc612/attachment.html>


More information about the cfe-dev mailing list