Skip to content

Fix compilation of foo.h: include <string> #19

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

Merged

Conversation

vasild
Copy link
Contributor

@vasild vasild commented Jan 17, 2020

std::string is used inside foo.h but it forgot to include the
corresponding header:

[ 53%] Building CXX object CMakeFiles/mptest.dir/src/mp/test/foo.capnp.proxy-server.c++.o
/usr/bin/c++   -I/usr/local/lib/cmake/CapnProto/../../../include -IBUILD/libmultiprocess/include -ISOURCE/libmultiprocess/include -ISOURCE/libmultiprocess/src -IBUILD/libmultiprocess/src -isystem /usr/local/include -D_THREAD_SAFE -pthread -std=gnu++14 -o CMakeFiles/mptest.dir/src/mp/test/foo.capnp.proxy-server.c++.o -c BUILD/libmultiprocess/src/mp/test/foo.capnp.proxy-server.c++
In file included from BUILD/libmultiprocess/src/mp/test/foo.capnp.proxy-server.c++:3:
In file included from BUILD/libmultiprocess/src/mp/test/foo.capnp.proxy-types.h:6:
In file included from BUILD/libmultiprocess/src/mp/test/foo.capnp.proxy.h:7:
SOURCE/libmultiprocess/src/mp/test/foo.h:17:17: error: implicit
      instantiation of undefined template 'std::__1::basic_string<char, std::__1::char_traits<char>,
      std::__1::allocator<char> >'
    std::string name;
                ^
/usr/include/c++/v1/iosfwd:210:32: note: template is declared here
    class _LIBCPP_TEMPLATE_VIS basic_string;
                               ^
1 error generated.
...

$ c++ --version
FreeBSD clang version 8.0.1 (tags/RELEASE_801/final 366581) (based on LLVM 8.0.1)
Target: x86_64-unknown-freebsd12.1
Thread model: posix
InstalledDir: /usr/bin

std::string is used inside foo.h but it forgot to include the
corresponding header:

```
[ 53%] Building CXX object CMakeFiles/mptest.dir/src/mp/test/foo.capnp.proxy-server.c++.o
/usr/bin/c++   -I/usr/local/lib/cmake/CapnProto/../../../include -IBUILD/libmultiprocess/include -ISOURCE/libmultiprocess/include -ISOURCE/libmultiprocess/src -IBUILD/libmultiprocess/src -isystem /usr/local/include -D_THREAD_SAFE -pthread -std=gnu++14 -o CMakeFiles/mptest.dir/src/mp/test/foo.capnp.proxy-server.c++.o -c BUILD/libmultiprocess/src/mp/test/foo.capnp.proxy-server.c++
In file included from BUILD/libmultiprocess/src/mp/test/foo.capnp.proxy-server.c++:3:
In file included from BUILD/libmultiprocess/src/mp/test/foo.capnp.proxy-types.h:6:
In file included from BUILD/libmultiprocess/src/mp/test/foo.capnp.proxy.h:7:
SOURCE/libmultiprocess/src/mp/test/foo.h:17:17: error: implicit
      instantiation of undefined template 'std::__1::basic_string<char, std::__1::char_traits<char>,
      std::__1::allocator<char> >'
    std::string name;
                ^
/usr/include/c++/v1/iosfwd:210:32: note: template is declared here
    class _LIBCPP_TEMPLATE_VIS basic_string;
                               ^
1 error generated.
...

$ c++ --version
FreeBSD clang version 8.0.1 (tags/RELEASE_801/final 366581) (based on LLVM 8.0.1)
Target: x86_64-unknown-freebsd12.1
Thread model: posix
InstalledDir: /usr/bin
```
@ryanofsky
Copy link
Collaborator

Code review ACK c92112a.

Good catch, a missing include also caused some problems for me in #16 (comment). A long time ago I had IWYU working on this code. I should probably get that working again to avoid more bugs like these.

ryanofsky added a commit that referenced this pull request Jan 17, 2020
c92112a Fix compilation of foo.h: include <string> (Vasil Dimov)

Pull request description:

  std::string is used inside foo.h but it forgot to include the
  corresponding header:

  ```
  [ 53%] Building CXX object CMakeFiles/mptest.dir/src/mp/test/foo.capnp.proxy-server.c++.o
  /usr/bin/c++   -I/usr/local/lib/cmake/CapnProto/../../../include -IBUILD/libmultiprocess/include -ISOURCE/libmultiprocess/include -ISOURCE/libmultiprocess/src -IBUILD/libmultiprocess/src -isystem /usr/local/include -D_THREAD_SAFE -pthread -std=gnu++14 -o CMakeFiles/mptest.dir/src/mp/test/foo.capnp.proxy-server.c++.o -c BUILD/libmultiprocess/src/mp/test/foo.capnp.proxy-server.c++
  In file included from BUILD/libmultiprocess/src/mp/test/foo.capnp.proxy-server.c++:3:
  In file included from BUILD/libmultiprocess/src/mp/test/foo.capnp.proxy-types.h:6:
  In file included from BUILD/libmultiprocess/src/mp/test/foo.capnp.proxy.h:7:
  SOURCE/libmultiprocess/src/mp/test/foo.h:17:17: error: implicit
        instantiation of undefined template 'std::__1::basic_string<char, std::__1::char_traits<char>,
        std::__1::allocator<char> >'
      std::string name;
                  ^
  /usr/include/c++/v1/iosfwd:210:32: note: template is declared here
      class _LIBCPP_TEMPLATE_VIS basic_string;
                                 ^
  1 error generated.
  ...

  $ c++ --version
  FreeBSD clang version 8.0.1 (tags/RELEASE_801/final 366581) (based on LLVM 8.0.1)
  Target: x86_64-unknown-freebsd12.1
  Thread model: posix
  InstalledDir: /usr/bin
  ```

ACKs for top commit:
  ryanofsky:
    Code review ACK c92112a.

Tree-SHA512: bac665541932d826e5c0ed2881860c3d011a041699c6005af5266bb27e82b3961646375e16c329a0b2b7c29214cdd4397a8aaabf7ca2c03efa2413e9cc9b9ca4
@ryanofsky ryanofsky merged commit c92112a into bitcoin-core:master Jan 17, 2020
@vasild vasild deleted the fix-compilation-include-string branch January 17, 2020 19:43
@vasild
Copy link
Contributor Author

vasild commented Jan 17, 2020

A long time ago I had IWYU working on this code. I should probably get that working again to avoid more bugs like these.

#20 Integrate iwyu
so that it does not get forgotten.

@bitcoin-core bitcoin-core locked and limited conversation to collaborators Jun 25, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants