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

Build error: expected unqualified-id before string constant (mingw32) #98822

Closed
roalyr opened this issue Nov 4, 2024 · 9 comments · Fixed by #99036 or #102255
Closed

Build error: expected unqualified-id before string constant (mingw32) #98822

roalyr opened this issue Nov 4, 2024 · 9 comments · Fixed by #99036 or #102255

Comments

@roalyr
Copy link

roalyr commented Nov 4, 2024

Tested versions

4.x as of 1bffd6c

System information

i686-w64-mingw32-gcc (GCC) 10-win32 20210110;   x86_64-w64-mingw32-gcc (GCC) 10-posix 20210110
System:    Kernel: 5.10.0-33-amd64 [5.10.226-1] x86_64 bits: 64 compiler: gcc v: 10.2.1 
           parameters: BOOT_IMAGE=/boot/vmlinuz-5.10.0-33-amd64 root=UUID=<filter> ro 
           Desktop: Xfce 4.18.1 tk: Gtk 3.24.24 info: xfce4-panel wm: xfwm 4.18.0 vt: 7 
           dm: LightDM 1.26.0 Distro: MX-21.3_x64 Wildflower January 15  2023 
           base: Debian GNU/Linux 11 (bullseye)

Issue description

Building for windows on Linux as follows:

#!/bin/sh

# For windows
export MINGW32_PREFIX="/usr/bin/i686-w64-mingw32-"
export MINGW64_PREFIX="/usr/bin/x86_64-w64-mingw32-"

# For incremental
export SCONS_CACHE="./scons_cache/godot_4_scons_cache_windows";
mkdir -p $SCONS_CACHE
mkdir -p "./logs"

${MINGW32_PREFIX}gcc --version
${MINGW64_PREFIX}gcc --version

# Editor (tools)
scons -j2 platform=windows precision=double 2>&1 | tee ./logs/godot_4_scons_windows_64_tools_build.txt;

# Template(s)
scons -j2 platform=windows precision=double target=template_debug arch=x86_64 2>&1 | tee ./logs/godot_4_scons_windows_64_template_build.txt;

Getting error:

...
Compiling thirdparty/libbacktrace/simple.c ...
In file included from /usr/share/mingw-w64/include/corecrt.h:10,
                 from /usr/share/mingw-w64/include/crtdefs.h:10,
                 from /usr/share/mingw-w64/include/stddef.h:7,
                 from /usr/lib/gcc/x86_64-w64-mingw32/10-posix/include/stddef.h:1,
                 from ./core/typedefs.h:34,
                 from ./core/object/object_id.h:34,
                 from ./core/error/error_macros.h:34,
                 from ./core/os/mutex.h:34,
                 from drivers/wasapi/audio_driver_wasapi.h:36,
                 from drivers/wasapi/audio_driver_wasapi.cpp:33:
drivers/wasapi/audio_driver_wasapi.cpp:89:1: error: expected unqualified-id before string constant
   89 | __CRT_UUID_DECL(IAudioClient3, 0x7ED4EE07, 0x8E67, 0x4CD4, 0x8C, 0x1A, 0x2B, 0x7A, 0x59, 0x87, 0xAD, 0x42)
      | ^~~~~~~~~~~~~~~
scons: *** [drivers/wasapi/audio_driver_wasapi.windows.template_debug.double.x86_64.o] Error 1

Steps to reproduce

Build from source.

Minimal reproduction project (MRP)

@roalyr roalyr changed the title Build error: error: expected unqualified-id before string constant (mingw32) Build error: expected unqualified-id before string constant (mingw32) Nov 4, 2024
@akien-mga akien-mga added this to the 4.4 milestone Nov 4, 2024
@akien-mga
Copy link
Member

I don't reproduce the issue on Fedora 41 with mingw-gcc 14.2.1 20240801.

You seem to have a fairly old versions of mingw (GCC 10-win32 20210110), which system are you on?

Please provide more information in your issues, I can luckily extract from the error message that you're building for Windows x86_64, template_debug, with double=yes, but this should be stated explicitly and with the full build command you're using when reporting build issues.

We might just need to up our minimum supported GCC/mingw version, or maybe find a workaround for the missing define in old mingw.

CC @bruvzg

@github-project-automation github-project-automation bot moved this to For team assessment in Buildsystem Issue Triage Nov 4, 2024
@akien-mga akien-mga moved this from For team assessment to Needs further info in Buildsystem Issue Triage Nov 4, 2024
@bruvzg
Copy link
Member

bruvzg commented Nov 4, 2024

The only recent change to this code seems to be #97934, but it's pretty strange that removing ; can cause it.

@roalyr
Copy link
Author

roalyr commented Nov 4, 2024

My bad. Here are details:

System:    Kernel: 5.10.0-33-amd64 [5.10.226-1] x86_64 bits: 64 compiler: gcc v: 10.2.1 
           parameters: BOOT_IMAGE=/boot/vmlinuz-5.10.0-33-amd64 root=UUID=<filter> ro 
           Desktop: Xfce 4.18.1 tk: Gtk 3.24.24 info: xfce4-panel wm: xfwm 4.18.0 vt: 7 
           dm: LightDM 1.26.0 Distro: MX-21.3_x64 Wildflower January 15  2023 
           base: Debian GNU/Linux 11 (bullseye) [/CODE]

https://github.com/roalyr/godot-for-3d-open-worlds/blob/master/rebuild_windows.sh

@bruvzg
Copy link
Member

bruvzg commented Nov 4, 2024

Debian GNU/Linux 11 (bullseye)

It's likely not GCC version, but MinGW headers version issue, bullseye package seems to be 8.0.0-1, that's definitely too old (not sure whether 9.0.0 or 10.0.0 is min. required, current version is 12.0.0).

@roalyr
Copy link
Author

roalyr commented Nov 4, 2024

I was building it two weeks ago and it worked. Also I am on MX Linux, its i686-w64-mingw32-c++-posix is 10.2.1-6

@roalyr
Copy link
Author

roalyr commented Nov 10, 2024

Will try to build it with LLVM instead.

clang version 19.1.3 (https://github.com/llvm/llvm-project.git ab51eccf88f5321e7c60591c5546b254b6afab99)
Target: x86_64-w64-windows-gnu
Thread model: posix

@roalyr
Copy link
Author

roalyr commented Nov 10, 2024

I am getting this error: #97882

Build code is as follows:

#!/bin/sh

# For windows
export MINGW_PREFIX="$HOME/llvm-mingw-20241030-ucrt-ubuntu-20.04-x86_64"

# For incremental
export SCONS_CACHE="./scons_cache/godot_4_scons_cache_windows";
mkdir -p $SCONS_CACHE
mkdir -p "./logs"

${MINGW_PREFIX}/bin/x86_64-w64-mingw32-gcc --version

# Editor (tools)
scons -j2 platform=windows use_llvm=yes precision=double arch=x86_64 2>&1 | tee ./logs/godot_4_scons_windows_64_tools_build.txt;

# Template(s)
scons -j2 platform=windows use_llvm=yes precision=double target=template_debug arch=x86_64 2>&1 | tee ./logs/godot_4_scons_windows_64_template_build.txt;

Error:

Linking Program bin/godot.windows.template_debug.double.x86_64.llvm.exe ...
ld.lld: error: duplicate symbol: PKEY_Device_FriendlyName
>>> defined at drivers/wasapi/audio_driver_wasapi.windows.template_debug.double.x86_64.llvm.o
>>> defined at /home/runner/work/llvm-mingw/llvm-mingw/install/llvm-mingw/x86_64-w64-mingw32/include/functiondiscoverykeys_devpkey.h:21
>>>            libuuid.a(lib64_libuuid_a-uuid.o)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
scons: *** [bin/godot.windows.template_debug.double.x86_64.llvm.exe] Error 1
scons: building terminated because of errors.

@bruvzg
Copy link
Member

bruvzg commented Nov 10, 2024

It's probably won't help, but try:

diff --git a/drivers/wasapi/audio_driver_wasapi.cpp b/drivers/wasapi/audio_driver_wasapi.cpp
index b5cb8da249..dfded0e237 100644
--- a/drivers/wasapi/audio_driver_wasapi.cpp
+++ b/drivers/wasapi/audio_driver_wasapi.cpp
@@ -85,7 +85,7 @@ public:
 			_In_ const WAVEFORMATEX *pFormat,
 			/* [annotation][in] */
 			_In_opt_ LPCGUID AudioSessionGuid) = 0;
-}
+};
 __CRT_UUID_DECL(IAudioClient3, 0x7ED4EE07, 0x8E67, 0x4CD4, 0x8C, 0x1A, 0x2B, 0x7A, 0x59, 0x87, 0xAD, 0x42)
 
 #endif // __IAudioClient3_INTERFACE_DEFINED__

Also I am on MX Linux, its i686-w64-mingw32-c++-posix is 10.2.1-6

What's mingw-w64-common version (one with the headers, not sure if name is the same on MX Linux)?

@roalyr
Copy link
Author

roalyr commented Nov 14, 2024

mingw-w64-common is 8.0.0-1 on my version of MX Linux (there is a newer one, but I didn't upgrade for two years).
But there were no prior issues compiling for windows on this platform up to the point mentioned in the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment