Skip to content

Potential Regression on #4189: Incorrectly attempting to link flockfile #4646

@mvastola

Description

@mvastola

Hi,
So I'm running into the same issue identified in #4189. I'm trying to compile fmt for use on a Raspberry Pi Pico 2 (with the official pico-sdk). I'm using the latest release (12.1.0).

I'm assuming the issue has to do with the function being defined in the headers but not any of the linked libraries (as this is for a micro-controller without an OS or, thus, any filesystems).

If there isn't a way to properly disable this using existing compile flags/checks, can one be added?
As a workaround I'm currently just commenting out these lines:

fmt/include/fmt/format-inl.h

Lines 1481 to 1483 in 407c905

template <typename F>
struct has_flockfile<F, void_t<decltype(flockfile(&std::declval<F&>()))>>
: std::true_type {};


As a potential aside (not sure if it's relevant), I'm having a bit of difficulty fully debugging the issue because I can see the enable_if-style guard for has_flockfile checks for the existence of the f(un)lockfile functions, but functions of this name are literally defined within fmt, so I'm honestly not sure if it's the standard library headers or fmt itself that is creating the belief the f(un)lockfile functions exist.

I also can't make heads or tails of the functions within fmt of that name because they depend on functions named _(un)lock_file, and I wasn't able to figure out where they are supposed to be defined.

fmt/include/fmt/format-inl.h

Lines 1465 to 1470 in 407c905

template <typename F> auto flockfile(F* f) -> decltype(_lock_file(f)) {
_lock_file(f);
}
template <typename F> auto funlockfile(F* f) -> decltype(_unlock_file(f)) {
_unlock_file(f);
}

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