Skip to content
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

[v2] MSVC Compilation Error with _get_osfhandle Function #431

Closed
UMU618 opened this issue Dec 1, 2024 · 3 comments
Closed

[v2] MSVC Compilation Error with _get_osfhandle Function #431

UMU618 opened this issue Dec 1, 2024 · 3 comments

Comments

@UMU618
Copy link

UMU618 commented Dec 1, 2024

1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\ucrt\corecrt_io.h(195,31): error C2375: 'boost::process::v2::detail::_get_osfhandle': redefinition; different linkage
1>(compiling source file '/src/runner_manager.cpp')
1>    src\vcpkg_installed\x64-windows\x64-windows\include\boost\process\v2\stdio.hpp(34,47):
1>    see declaration of 'boost::process::v2::detail::_get_osfhandle'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\ucrt\corecrt_io.h(195,31): error C2733: '_get_osfhandle': you cannot overload a function with 'extern "C"' linkage
1>(compiling source file '/src/runner_manager.cpp')
1>    src\vcpkg_installed\x64-windows\x64-windows\include\boost\process\v2\stdio.hpp(34,47):
1>    see declaration of 'boost::process::v2::detail::_get_osfhandle'

To fix, add a BOOST_SYMBOL_IMPORT:

BOOST_PROCESS_V2_BEGIN_NAMESPACE
namespace detail
{
#if defined(BOOST_PROCESS_V2_WINDOWS)

extern "C" BOOST_SYMBOL_IMPORT intptr_t _get_osfhandle(int fd);

struct handle_closer
@klemens-morgenstern
Copy link
Collaborator

Thanks for reporting.

This generally looks correct, but i'd need to make sure it won't breake stuff somewhere else (like cross compiling). And I might just remove the forward declaration and include <io.h>

Are you including <io.h> before or after process ?

@UMU618
Copy link
Author

UMU618 commented Dec 2, 2024

There's no <io.h> included explictly.

runner_manager.h:

#pragma once

#include <memory>

#include <boost/asio.hpp>
#include <boost/process/v2/popen.hpp>

runner_manager.cpp:

#include "pch.h"

#include "runner_manager.h"

#include <boost/process/v2/windows/as_user_launcher.hpp>

pch.h:

#pragma once

#define WIN32_LEAN_AND_MEAN
#include <windows.h>

#include <array>
#include <cstddef>
#include <cstdint>
#include <map>
#include <memory>
#include <mutex>
#include <set>
#include <string>
#include <string_view>
#include <vector>

#include <boost/assert.hpp>
#include <boost/scope/defer.hpp>

#include <gsl/gsl>

@klemens-morgenstern
Copy link
Collaborator

Thanks for the details.

I'll probably just end up including io.h, since windows.h comes in via asio anyhow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants