Bug of juce_win32_Windowing.cpp

I was building the code using GCC. The 64-bit version built fine, but the 32-bit version gave bugs in file juce_win32_Windowing.cpp (Juce V6).
1.
if (hImc != nullptr && (lParam & GCS_COMPCLAUSE) != 0)

4046 | error: invalid operands of types ‘HIMC’ {aka ‘long unsigned int’} and ‘std::nullptr_t’ to binary ‘operator!=’

header.bV5CSType = LCS_WINDOWS_COLOR_SPACE;

962 | error: ‘LCS_WINDOWS_COLOR_SPACE’ was not declared in this scope

I changed these lines like this and everything came together:
1.
if (hImc != 0 && (lParam & GCS_COMPCLAUSE) != 0)
2.
header.bV5CSType = 0xFFFFFFFF;

I tried reproducing the the errors you mentioned by building on Windows 10 with g++ 8.1, which is provided via MinGW-w64 and bundled with CodeBlocks 20.03. I don’t see the same errors, so I think you must be using a different compiler and/or OS.

Can you provide more details about how you’re building JUCE please?

You mention building with GCC, but you’re seeing errors in Windows-specific files. Which OS are you using to build (Windows with WSL, Windows with MinGW, Linux with MinGW)? Are you using a project generated by CMake or by the Projucer? It might also be useful to know the compiler version you’re using.

I am using CodeBlocks 20.03 and TDM-GCC-32 on Windows. The project was created with Projucer.
TDM-GCC-64 gives an -ld error with -m32, so I use TDM-GCC-32.
Maybe due to warnings:
1)
modules\juce_core\time\juce_Time.cpp
#warning “Can’t find a replacement for tzset on mingw - ideas welcome!”
2)
modules\juce_graphics\juce_graphics.cpp
#if JUCE_MINGW && JUCE_USE_DIRECTWRITE
#warning “DirectWrite not currently implemented with mingw…”

And further. When I used tdm-gcc-32-10.3.0, the application was putting a heavy load on the processor. And with tdm-gcc-32-5.1.0, the load dropped close to zero. And tdm-gcc-64-10.3.0 on a 64-bit application does not give a lot of load.

I’m not really sure how this is building for you. Here, when I build with TDM-GCC-32, I get an error in shellapi.h saying that REFIID is undeclared. The line containing the reference to REFIID is only built if _WIN32_WINNT is set to 0x0600 or greater, but currently juce_BasicNativeHeaders.h sets _WIN32_WINNT to 0x0600 before including any windows headers. I also see a few more errors about undeclared identifiers after that.

TDM-GCC is not officially supported by JUCE, and MinGW only has limited support. I’d recommend to try building with the MinGW bundled with CodeBlocks 20.03 and see whether that resolves the issue. Otherwise, you might consider building with Clang, which is better-supported than MinGW on Windows.

Well, I have already built the program, taking into account the above amendments. Everything works. You can also try TDM-GCC-64.

Here is a working project for CodeBlocks. It was made with Projucer which was built in Visual Studio.

HelloWorldDemo.zip (57.1 KB)

I’ve pushed some fixes which might resolve the issue:

However, as I said previously, this compiler is not officially supported and would not work at all for me. I’d recommend switching to a better-supported compiler if possible (clang is very good on Windows).

1 Like

I tried MinGW instead of TDM-GCC. Applications built with it require libwinpthread-1.dll, libstdc ++ - 6.dll, and others. TDM-GCC is free of this.