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

FMT_USE_FCNTL in os.h only defines fmt::output_file for non-windows OS #2277

Closed
zcream opened this issue May 11, 2021 · 2 comments
Closed

FMT_USE_FCNTL in os.h only defines fmt::output_file for non-windows OS #2277

zcream opened this issue May 11, 2021 · 2 comments

Comments

@zcream
Copy link

zcream commented May 11, 2021

The current implementation of fmt::output_file is only for non-Windows OS when FMT_USE_FCNTL is 1.
This is a bad design philosophy leading to code that is not-compatible across OS'es. As a resolution, either fmt::output_file and related methods should be defined for Windows or they should be removed to maintain OS-agnostic behavior.

@vitaut
Copy link
Contributor

vitaut commented May 11, 2021

output_file does support compatible Windows versions. Note that some of the APIs in fmt/os.h are inherently nonportable so if you want maximum portability use buffered_file instead of output_file.

@vitaut vitaut closed this as completed May 11, 2021
@timkalu
Copy link
Contributor

timkalu commented Oct 28, 2021

os.h should accept a predefined FMT_USE_FCNTL override so using FMT with e.g. the NXP toolchain for ARM (under FreeRTOS) does not have a fnctl call.

How about this:
os.h:

#ifndef FMT_USE_FCNTL
// UWP doesn't provide _pipe.
#  if FMT_HAS_INCLUDE("winapifamily.h")
#    include <winapifamily.h>
#  endif
#  if (FMT_HAS_INCLUDE(<fcntl.h>) || defined(__APPLE__) || \
       defined(__linux__)) &&                              \
      (!defined(WINAPI_FAMILY) || (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP))
#  i  nclude <fcntl.h>  // for O_RDONLY
#    define FMT_USE_FCNTL 1
#  else
#    define FMT_USE_FCNTL 0
#  endif
#endif

The detection of FMT_HAS_INCLUDE does not work correctly for this toolchain.

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

3 participants