googletest icon indicating copy to clipboard operation
googletest copied to clipboard

[Bug]: Build failure on Windows with gcc 15.2: error: standard attributes in middle of decl-specifiers

Open WardBrian opened this issue 2 months ago • 1 comments

Describe the issue

Starting with the most recent commit 065127f1e4b46c5f14fc73cf8d323c221f9dc68e, building on Windows with gcc 15.2 raises an error:

 D:/a/walnuts/walnuts/build/_deps/googletest-src/googlemock/include/gmock/internal/gmock-internal-utils.h:304:7: error: standard attributes in middle of decl-specifiers
  304 |       GTEST_API_
      |       ^~~~~~~~~~
D:/a/walnuts/walnuts/build/_deps/googletest-src/googlemock/include/gmock/internal/gmock-internal-utils.h:304:7: note: standard attributes must precede the decl-specifiers to apply to the declaration, or follow them to apply to the type

These lines did indeed change in the commit that originates the problem.

Steps to reproduce the problem

See github actions: https://github.com/flatironinstitute/walnuts/actions/runs/20106717581/job/57714011338

What version of GoogleTest are you using?

065127f1e4b46c5f14fc73cf8d323c221f9dc68e

What operating system and version are you using?

Windows

What compiler and version are you using?

gcc 15.2.0

What build system are you using?

cmake

Additional context

No response

WardBrian avatar Dec 10 '25 21:12 WardBrian

Still have the same issue on the latest commit of googletest, on windows-2025, building with ninja and GNU 15.2.0, with CXX_STANDARD 23

D:/a/Cross-API-Engine/Cross-API-Engine/third-party/googletest/googlemock/include/gmock/internal/gmock-internal-utils.h:304:7: error: standard attributes in middle of decl-specifiers
 304 |       GTEST_API_
     |       ^~~~~~~~~~
D:/a/Cross-API-Engine/Cross-API-Engine/third-party/googletest/googlemock/include/gmock/internal/gmock-internal-utils.h:304:7: note: standard attributes must precede the decl-specifiers to apply to the declaration, or follow them to apply to the type

ref: https://github.com/bobis33/Cross-API-Engine/actions/runs/20338495352/job/58431090646

bobis33 avatar Dec 18 '25 14:12 bobis33

It also fails in for gcc-15.1.0 on Windows (toolchain: winlibs-x86_64-posix-seh-gcc-15.1.0-mingw-w64ucrt-13.0.0-r2)

C:/Users/jancu/Documents/Pico/workspace_sdk2.0.0/callbackmanager/build/_deps/googletest-src/googlemock/include/gmock/internal/gmock-internal-utils.h:304:7: error: standard attributes in middle of decl-specifiers
  304 |       GTEST_API_
      |       ^~~~~~~~~~
C:/Users/jancu/Documents/Pico/workspace_sdk2.0.0/callbackmanager/build/_deps/googletest-src/googlemock/include/gmock/internal/gmock-internal-utils.h:304:7: note: standard attributes must precede the decl-specifiers to apply to the declaration, or follow them to apply to the type

I use this workaround: I fetch googletest from github with tag v1.17.0 instead of HEAD.

jancumps avatar Dec 24 '25 14:12 jancumps

I encountered the same build failure on Windows with GCC 15.2.0 Actions using googletest as a submodule (latest commit 9156d4caac880b513264ecbe0aa4746a3fead3d7). The error occurs in gmock-internal-utils.h line 304 with the same diagnostic:

D:/a/tziakcha_record_miner/tziakcha_record_miner/third_party/googletest/googlemock/include/gmock/internal/gmock-internal-utils.h:304:7: error: standard attributes in middle of decl-specifiers
  304 |       GTEST_API_
      |       ^~~~~~~~~~
D:/a/tziakcha_record_miner/tziakcha_record_miner/third_party/googletest/googlemock/include/gmock/internal/gmock-internal-utils.h:304:7: note: standard attributes must precede the decl-specifiers to apply to the declaration, or follow them to apply to the type

Choimoe avatar Jan 05 '26 17:01 Choimoe