https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102341

Pilar Latiesa <pilarlatiesa at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pilarlatiesa at gmail dot com

--- Comment #4 from Pilar Latiesa <pilarlatiesa at gmail dot com> ---
In PR98885#C1 Nathan said that "an exported entity must be so-declared on its
first declaration".


Would it be possible to forward-declare every exported entity and then
`#include`ing all the headers?

I mean something along the lines:

$ cat borrar.h

namespace Test
{
  template<typename T>
  class valarray {};
}

$ cat borrar.cpp

export module Test;

namespace Test
{
  export
  template<typename T>
  class valarray;
}

#include "borrar.h"

$ cat main.cpp

import Test;

int main()
{
  Test::valarray<double> v;
  return 0;
}

$ g++-11 -Wall -Wextra -fmodules-ts borrar.cpp main.cpp
main.cpp: In function ‘int main()’:
main.cpp:6:26: warning: unused variable ‘v’ [-Wunused-variable]
    6 |   Test::valarray<double> v;
      |                          ^

However, I don't think that this approach can be used to split the library into
several modules.

Reply via email to