Skip to content

[Compilation Error] Error when including <windows.h> before <rfl/Result.hpp> #560

@NiNeDelixe

Description

@NiNeDelixe

Description

There is a compilation error when including Windows headers before the librarys Result.hpp file. The compilation succeeds only when the include order is reversed.

Steps to Reproduce

Failing case (Windows headers first):

#include <windows.h>
#include <rfl/Result.hpp>

Attempt to compile the code

Observe compilation errors

Workaround (compiles successfully):

#include <rfl/Result.hpp>
#include <windows.h>

Expected Behavior

The code should compile successfully regardless of the include order.

Actual Behavior

Compilation fails with errors when <windows.h> is included before <rfl/Result.hpp>.

Error Messages

[main] Building folder: D:/source/PRD4210/COURSE_WORK/Ulin/out/build/x86-debug 
[build] Starting build
[proc] Executing command: "D:\Program Files\CMake\bin\cmake.EXE" --build D:/source/PRD4210/COURSE_WORK/Ulin/out/build/x86-debug --
[build] [1/2] Building CXX object _exec\backend\CMakeFiles\backend.dir\main.cpp.obj
[build] FAILED: [code=2] _exec/backend/CMakeFiles/backend.dir/main.cpp.obj 
[build] "D:\ProgramFiles\Microsoft VisualStudio\VC\Tools\MSVC\14.44.35207\bin\Hostx64\x86\cl.exe"  /nologo /TP -DYYJSON_IMPORTS -ID:\source\PRD4210\COURSE_WORK\Ulin\thirdparty\cpp-static-block -ID:\source\PRD4210\COURSE_WORK\Ulin\src\backend -ID:\source\PRD4210\COURSE_WORK\Ulin\thirdparty\dotenv-cpp\include\laserpants\dotenv -external:ID:\source\PRD4210\COURSE_WORK\Ulin\out\build\x86-debug\vcpkg_installed\x86-windows\include -external:W0 /DWIN32 /D_WINDOWS /GR /EHsc /Zi /Ob0 /Od /RTC1 -std:c++20 -MDd /wd4251 /wd4275 /showIncludes /Fo_exec\backend\CMakeFiles\backend.dir\main.cpp.obj /Fd_exec\backend\CMakeFiles\backend.dir\ /FS -c D:\source\PRD4210\COURSE_WORK\Ulin\src\backend\main.cpp
[build] D:\source\PRD4210\COURSE_WORK\Ulin\out\build\x86-debug\vcpkg_installed\x86-windows\include\rfl/Result.hpp(83): error C2589: (: invalid lexeme to the right of "::"
[build] D:\source\PRD4210\COURSE_WORK\Ulin\out\build\x86-debug\vcpkg_installed\x86-windows\include\rfl/Result.hpp(83): note: template instantiation context (oldest first)
[build] D:\source\PRD4210\COURSE_WORK\Ulin\out\build\x86-debug\vcpkg_installed\x86-windows\include\rfl/Result.hpp(80): note: when compiling the class template "rfl::Result"
[build] D:\source\PRD4210\COURSE_WORK\Ulin\out\build\x86-debug\vcpkg_installed\x86-windows\include\rfl/Result.hpp(83): error C2059: syntax error: )
[build] D:\source\PRD4210\COURSE_WORK\Ulin\out\build\x86-debug\vcpkg_installed\x86-windows\include\rfl/Result.hpp(83): error C2947: required ">" to complete template argument list, detected ">"
[build] ninja: build stopped: subcommand failed.
[proc] The command: "D:\Program Files\CMake\bin\cmake.EXE" --build D:/source/PRD4210/COURSE_WORK/Ulin/out/build/x86-debug -- exited with code: 2
[driver] Build completed: 00:00:01.194
[build] Build finished with exit code 2

Environment

Compiler Version: MSVC 19.44.35217 for x86
Library Version: From current vcpkg version
Operating System: Windows
Build System: Cmake minimum 4.2

CmakeLists.txt

CMakePresets.json

vcpkg.json

main.cpp

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions