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

Fix warning C4251: class fmt::v8::file needs to have dll-interface #2797

Merged
merged 2 commits into from
Mar 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions include/fmt/os.h
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ class buffered_file {
// closing the file multiple times will cause a crash on Windows rather
// than an exception. You can get standard behavior by overriding the
// invalid parameter handler with _set_invalid_parameter_handler.
class file {
class FMT_API file {
private:
int fd_; // File descriptor.

Expand All @@ -304,7 +304,7 @@ class file {
file() noexcept : fd_(-1) {}

// Opens a file and constructs a file object representing this file.
FMT_API file(cstring_view path, int oflag);
file(cstring_view path, int oflag);

public:
file(const file&) = delete;
Expand All @@ -321,43 +321,43 @@ class file {
}

// Destroys the object closing the file it represents if any.
FMT_API ~file() noexcept;
~file() noexcept;

// Returns the file descriptor.
int descriptor() const noexcept { return fd_; }

// Closes the file.
FMT_API void close();
void close();

// Returns the file size. The size has signed type for consistency with
// stat::st_size.
FMT_API long long size() const;
long long size() const;

// Attempts to read count bytes from the file into the specified buffer.
FMT_API size_t read(void* buffer, size_t count);
size_t read(void* buffer, size_t count);

// Attempts to write count bytes from the specified buffer to the file.
FMT_API size_t write(const void* buffer, size_t count);
size_t write(const void* buffer, size_t count);

// Duplicates a file descriptor with the dup function and returns
// the duplicate as a file object.
FMT_API static file dup(int fd);
static file dup(int fd);

// Makes fd be the copy of this file descriptor, closing fd first if
// necessary.
FMT_API void dup2(int fd);
void dup2(int fd);

// Makes fd be the copy of this file descriptor, closing fd first if
// necessary.
FMT_API void dup2(int fd, std::error_code& ec) noexcept;
void dup2(int fd, std::error_code& ec) noexcept;

// Creates a pipe setting up read_end and write_end file objects for reading
// and writing respectively.
FMT_API static void pipe(file& read_end, file& write_end);
static void pipe(file& read_end, file& write_end);

// Creates a buffered_file object associated with this file and detaches
// this file object from the file.
FMT_API buffered_file fdopen(const char* mode);
buffered_file fdopen(const char* mode);
};

// Returns the memory page size.
Expand Down
2 changes: 1 addition & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set(TEST_MAIN_SRC test-main.cc gtest-extra.cc gtest-extra.h util.cc)
add_library(test-main STATIC ${TEST_MAIN_SRC})
target_include_directories(test-main PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>)
target_link_libraries(test-main gtest)
target_link_libraries(test-main gtest fmt)

include(CheckCXXCompilerFlag)

Expand Down