← All tasks
cppcapnproto/capnproto #1351Not a task: already works

Cannot build the libs once they are installed

envgap__capnproto__capnproto-1351

01 / FAILURE SIGNATURE

As reported upstream

C:\Dev\crtdll\include\kj\common.h(288): error C2572: 'kj::_::inlineRequireFailure': redefinition of default argument: parameter 1
Not a benchmark task.
  • The project already builds and runs before the fix, so there is nothing to repair.

02 / ENVIRONMENT RECIPE

Base commit
c8189ec3c27dacbd4a3288e682473010e377f593
Manifest
c++/src/kj/CMakeLists.txt
Reproduce
Awaiting issue-specific recipe
Run under trace
Awaiting a meaningful runtime command

03 / ORIGINAL ISSUE TEXT

capnproto/capnproto #1351 · read the original issue
I am building `capnproto` using VS2019 (MSVC), `cmake` and `Ninja`. I am specifying `CMAKE_INSTALL_PREFIX` on command line for two reasons: 1) instruct the toolchain where to look for the additional dependencies (e.g. `zlib`), 2) have the `capnproto` libs installed there.



For example the command line options for the debug build look like this:

```

cmake.exe  -G "Ninja" ^

-DCMAKE_BUILD_TYPE:STRING="Debug" ^

-DCMAKE_INSTALL_PREFIX:PATH="C:\Dev\crtdll" ^

-DCMAKE_CXX_STANDARD=17 ^

-DCMAKE_EXPORT_COMPILE_COMMANDS=ON ^

-DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded$<$<CONFIG:Debug>:Debug>DLL" ^

"C:\Work_OSS\capnproto" 2>&1"

```



This builds fine as long as I do not install the library. Once the library is installed (into `C:\Dev\crtdll`) the build fails at the first target:

```

>------ Build All started: Project: capnproto, Configuration: x64-DLL-Debug ------

  [1/185] C:\PROGRA~2\MICROS~4\2019\COMMUN~1\VC\Tools\MSVC\1429~1.301\bin\Hostx64\x64\cl.exe  /nologo /TP  -IC:\Dev\crtdll\include -I..\..\..\c++\src /DWIN32 /D_WINDOWS /W3 /GR /EHsc /MDd /Zi /Ob0 /Od /RTC1   -D KJ_HAS_ZLIB=1 /wo4503 -std:c++17 /showIncludes /Foc++\src\kj\CMakeFiles\kj-tests.dir\string-test.c++.obj /Fdc++\src\kj\CMakeFiles\kj-tests.dir\ /FS -c ..\..\..\c++\src\kj\string-test.c++

  FAILED: c++/src/kj/CMakeFiles/kj-tests.dir/string-test.c++.obj 

  C:\PROGRA~2\MICROS~4\2019\COMMUN~1\VC\Tools\MSVC\1429~1.301\bin\Hostx64\x64\cl.exe  /nologo /TP  -IC:\Dev\crtdll\include -I..\..\..\c++\src /DWIN32 /D_WINDOWS /W3 /GR /EHsc /MDd /Zi /Ob0 /Od /RTC1   -D KJ_HAS_ZLIB=1 /wo4503 -std:c++17 /showIncludes /Foc++\src\kj\CMakeFiles\kj-tests.dir\string-test.c++.obj /Fdc++\src\kj\CMakeFiles\kj-tests.dir\ /FS -c ..\..\..\c++\src\kj\string-test.c++

  string-test.c++

C:\Dev\crtdll\include\kj\common.h(288): error C2572: 'kj::_::inlineRequireFailure': redefinition of default argument: parameter 1

  C:\Work_OSS\capnproto\c++\src\kj\common.h(288): note: see declaration of 'kj::_::inlineRequireFailure'

C:\Dev\crtdll\include\kj\common.h(414): error C2953: 'kj::NoInfer_': class template has already been defined

  C:\Dev\crtdll\include\kj\common.h(414): note: see declaration of 'kj::NoInfer_'

C:\Dev\crtdll\include\kj\common.h(415): error C2386: 'NoInfer': a symbol with this name already exists in the current scope

C:\Dev\crtdll\include\kj\common.h(419): error C2953: 'kj::RemoveConst_': class template has already been defined

  C:\Dev\crtdll\include\kj\common.h(419): note: see declaration of 'kj::RemoveConst_'

C:\Dev\crtdll\include\kj\common.h(420): error C2953: 'kj::RemoveConst_': class template has already been defined

  C:\Dev\crtdll\include\kj\common.h(420): note: see declaration of 'kj::RemoveConst_'

```

I guess the problem is that the lib implementation uses "double quote" and "angle-bracket" notation at the same time (to include the same header file), even in one file like this (snippet from `message.h`):

```

#pragma once



#include <kj/common.h>

#include <kj/memory.h>

#include <kj/mutex.h>

#include <kj/debug.h>

#include <kj/vector.h>

#include "common.h"

#include "layout.h"

#include "any.h"

```

This leads to compiler including the same file from two different locations and apparently `#pragma once` is not enough to recognize that. Once I delete the header files from the install path, it starts building fine. 



Apart from the obvious problem quoted above, I believe the problem may manifest at some other includes as well, as it seems that many are including `"common.h"`, but to which one it will resolve (the global or local one) will depend on where exactly the file including this resides relative to `common.h`.
Continue on GitHub ↗

04 / LABELS

Labels from the report text only; not yet run

No supported category has been assigned.

Label rules and the text that matched
[]