Skip to content

MINGW: Fix error of use of deleted function - #593

Merged
jerethk merged 1 commit into
TheForceEngine:masterfrom
carlo-bramini:fix-mingw-build
Jul 6, 2026
Merged

MINGW: Fix error of use of deleted function#593
jerethk merged 1 commit into
TheForceEngine:masterfrom
carlo-bramini:fix-mingw-build

Conversation

@carlo-bramini

Copy link
Copy Markdown
Contributor

I tried to build the engine with MinGW and I got several errors like this one:

TheForceEngine/TFE_FileSystem/filewriterAsync.cpp:29:43: error: use of deleted function ‘std::atomic<int>::atomic(const std::atomic<int>&)’
   29 |         std::atomic<s32> s_requestCount = 0;
      |                                           ^
In file included from TheForceEngine/TFE_System/types.h:6,
                 from TheForceEngine/TFE_System/system.h:8,
                 from TheForceEngine/TFE_FileSystem/filewriterAsync.h:2,
                 from TheForceEngine/TFE_FileSystem/filewriterAsync.cpp:1:
/usr/lib/gcc/x86_64-w64-mingw32/14/include/c++/atomic:834:7: note: declared here
  834 |       atomic(const atomic&) = delete;
      |       ^~~~~~
TheForceEngine/TFE_FileSystem/filewriterAsync.cpp:29:43: note: use ‘-fdiagnostics-all-candidates’ to display considered candidates
   29 |         std::atomic<s32> s_requestCount = 0;
      |                                           ^
/usr/lib/gcc/x86_64-w64-mingw32/14/include/c++/atomic:838:17: note:   after user-defined conversion: ‘constexpr std::atomic<int>::atomic(__integral_type)’
  838 |       constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
      |                 ^~~~~~

Attached patch fixes it.
Actually, this file doesn't seem to be compiled by the Visual Studio project file, so I could not test if this change works there too. However, I have been able to build the engine also with MSVC even after this fix.

@mlauss2

mlauss2 commented May 10, 2026

Copy link
Copy Markdown
Contributor

While your fix is in principle correct, the file itself is unused.
I think it's better to just exclude it from the build altogether:

index 31a3df93..c91698be 100644
--- a/TheForceEngine/TFE_FileSystem/CMakeLists.txt
+++ b/TheForceEngine/TFE_FileSystem/CMakeLists.txt
@@ -12,7 +12,6 @@ elseif(UNIX)
        )
 endif()
 target_sources(tfe PRIVATE
-               "${CMAKE_CURRENT_SOURCE_DIR}/filewriterAsync.cpp"
                "${CMAKE_CURRENT_SOURCE_DIR}/memorystream.cpp"
                )
 

@carlo-bramini

carlo-bramini commented May 12, 2026

Copy link
Copy Markdown
Contributor Author

Thank you for the reply.
For me it's ok if you prefer to close this PR and remove filewriterAsync.cpp from CMakeLists.txt.

EDIT: I did a test and I confirm that your solution also fixed the original issue.

@jerethk jerethk left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mlauss2 is correct, this file is not currently used by TFE.
However, the fix is appropriate and IMO worthwhile in case the file ever gets used in the future.

Feel free to also add a commit removing it from CMakelists.txt, if you wish. I am happy to approve for now.

@jerethk

jerethk commented Jul 4, 2026

Copy link
Copy Markdown
Collaborator

carlo-bramini by the way, as I understand it, the preferred syntax is

std::atomic<s32> s_requestCount{0};

If you are going to add the change to CMakeLists.txt do you want to also make this change?

I tried to build the engine with MinGW and I got several errors like this one:

TheForceEngine/TFE_FileSystem/filewriterAsync.cpp:29:43: error: use of deleted function ‘std::atomic<int>::atomic(const std::atomic<int>&)’
   29 |         std::atomic<s32> s_requestCount = 0;
      |                                           ^
In file included from TheForceEngine/TFE_System/types.h:6,
                 from TheForceEngine/TFE_System/system.h:8,
                 from TheForceEngine/TFE_FileSystem/filewriterAsync.h:2,
                 from TheForceEngine/TFE_FileSystem/filewriterAsync.cpp:1:
/usr/lib/gcc/x86_64-w64-mingw32/14/include/c++/atomic:834:7: note: declared here
  834 |       atomic(const atomic&) = delete;
      |       ^~~~~~
TheForceEngine/TFE_FileSystem/filewriterAsync.cpp:29:43: note: use ‘-fdiagnostics-all-candidates’ to display considered candidates
   29 |         std::atomic<s32> s_requestCount = 0;
      |                                           ^
/usr/lib/gcc/x86_64-w64-mingw32/14/include/c++/atomic:838:17: note:   after user-defined conversion: ‘constexpr std::atomic<int>::atomic(__integral_type)’
  838 |       constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
      |                 ^~~~~~

Attached patch fixes it.
Actually, this file doesn't seem to be compiled by the Visual Studio project file, so I could not test if this change works there too.
However, I have been able to build the engine also with MSVC even after this fix.
@carlo-bramini

Copy link
Copy Markdown
Contributor Author

carlo-bramini by the way, as I understand it, the preferred syntax is

std::atomic<s32> s_requestCount{0};

If you are going to add the change to CMakeLists.txt do you want to also make this change?

I did the changes.
Thank you very much for your support.

@jerethk
jerethk merged commit 1498182 into TheForceEngine:master Jul 6, 2026
2 checks passed
@carlo-bramini
carlo-bramini deleted the fix-mingw-build branch July 6, 2026 15:08
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

Successfully merging this pull request may close these issues.

3 participants