Menu

#2794 Windows : winmain.c fails to be complied

None
closed-fixed
nobody
None
2025-06-04
2025-05-07
No

In the git repository, windows build fails.

gcc -c -m64 -O2 -pipe -DUNICODE -D_UNICODE -Wno-unused-function -DGNUPLOT_PS_DIR=\"share/PostScript\" -I. -I../../src -I../../term/ -DHAVE_CONFIG_H -D__USE_MINGW_ANSI_STDIO=1 -DWITH_CHI_SHAPES=1 -DGNUPLOT_SHARE_DIR=\"share\" -DDEVELOPMENT_VERSION -DUSE_MOUSE=1 -DWIN_IPC -I/c/Program\ Files\ (x86)/HTML\ Help\ Workshop/include -DHAVE_LIBGD -DHAVE_LIBPNG -DHAVE_LIBGD -DHAVE_GD_H -DHAVE_GD_GIF -DGIF_ANIMATION -DHAVE_GD_PNG -IC:/Programs/msys64/mingw64/include/X11 -IC:/Programs/msys64/mingw64/include/webp -DLIBDEFLATE_DLL -IC:/Programs/msys64/mingw64/include/freetype2 -IC:/Programs/msys64/mingw64/include/libpng16 -IC:/Programs/msys64/mingw64/include/harfbuzz -IC:/Programs/msys64/mingw64/include/glib-2.0 -IC:/Programs/msys64/mingw64/lib/glib-2.0/include -DHAVE_GD_JPEG -DHAVE_GD_TTF -DHAVE_CAIROPDF -DHAVE_WEBP -DWXWIDGETS -DQTTERM -DQT_NO_OPENGL -DHAVE_LUA -DHAVE_ICONV -DHAVE_LIBCERF -DNEED_CEXP -DHAVE_AMOS -DREADLINE -DUSE_WATCHPOINTS -DUSE_POLAR_GRID -DUSE_FUNCTIONBLOCKS -DWITH_STABLE_SORT -DHAVE_D2D11 -DPIPES -MMD -MT 'winmain.o' -MF winmain.d -o winmain.o ../../src/win/winmain.c
../../src/win/winmain.c: In function 'appdata_directory':
../../src/win/winmain.c:287:14: error: too many arguments to function 'pSHGetSpecialFolderPath'; expected 0, have 4
287 | (*pSHGetSpecialFolderPath)(NULL, dir, CSIDL_APPDATA, FALSE);
| ~^~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~
make: *** [Makefile:679: winmain.o] Error 1

Discussion

  • Ethan Merritt

    Ethan Merritt - 2025-05-07

    Is it possible you have a new C compiler?

    The very recent gcc15 release has made a number of issues that used to be warnings into errors instead. This is apparently because of stricter requirements in the C23 standard. So if the error is from gcc15 you might be able to avoid it by adding the compiler flag -std=gnu17

    Or they might fix this in gcc. See
    https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118112

     

    Last edit: Ethan Merritt 2025-05-07
  • Tatsuro MATSUOKA

    Addtion of -std=gnu17 option to CFLAGS eliminates the issue.
    Thanks!

     
  • Tatsuro MATSUOKA

    Testted but an error appears

    gcc -c -m64 -O2 -pipe -DUNICODE -D_UNICODE -Wno-unused-function -DGNUPLOT_PS_DIR=\"share/PostScript\"  -I. -I../../src -I../../term/ -DHAVE_CONFIG_H -D__USE_MINGW_ANSI_STDIO=1 -DWITH_CHI_SHAPES=1 -DGNUPLOT_SHARE_DIR=\"share\" -DDEVELOPMENT_VERSION -DUSE_MOUSE=1 -DWIN_IPC -I/c/Program\ Files\ \(x86\)/HTML\ Help\ Workshop/include -DHAVE_LIBGD -DHAVE_LIBPNG -DHAVE_LIBGD -DHAVE_GD_H -DHAVE_GD_GIF -DGIF_ANIMATION -DHAVE_GD_PNG -IC:/Programs/msys64/mingw64/include/X11 -IC:/Programs/msys64/mingw64/include/webp -DLIBDEFLATE_DLL -IC:/Programs/msys64/mingw64/include/freetype2 -IC:/Programs/msys64/mingw64/include/libpng16 -IC:/Programs/msys64/mingw64/include/harfbuzz -IC:/Programs/msys64/mingw64/include/glib-2.0 -IC:/Programs/msys64/mingw64/lib/glib-2.0/include -DHAVE_GD_JPEG -DHAVE_GD_TTF -DHAVE_CAIROPDF -DHAVE_WEBP -DWXWIDGETS -DQTTERM -DQT_NO_OPENGL -DHAVE_LUA -DHAVE_ICONV -DHAVE_LIBCERF -DNEED_CEXP -DHAVE_AMOS -DREADLINE -DUSE_WATCHPOINTS -DUSE_POLAR_GRID -DUSE_FUNCTIONBLOCKS -DWITH_STABLE_SORT -DHAVE_D2D11 -DPIPES -MMD -MT 'winmain.o' -MF winmain.d -o winmain.o ../../src/win/winmain.c
    ../../src/win/winmain.c: In function 'appdata_directory':
    ../../src/win/winmain.c:279:17: error: redefinition of 'dir'
      279 |     static char dir[MAX_PATH] = "";
          |                 ^~~
    ../../src/win/winmain.c:277:18: note: previous definition of 'dir' with type 'char[260]'
      277 |      static char dir[MAX_PATH] = "";
          |                  ^~~
    ../../src/win/winmain.c:289:33: error: assignment to 'GETFOLDERPATH' {aka 'unsigned int (*)(struct HWND__ *, char *, int,  int)'} from incompatible pointer type 'FARPROC' {aka 'long long int (*)(void)'} [-Wincompatible-pointer-types]
      289 |         pSHGetSpecialFolderPath =
          |                                 ^
    ../../src/win/winmain.c:274:29: note: 'GETFOLDERPATH' declared here
      274 |     typedef UINT (CALLBACK* GETFOLDERPATH)
          |                             ^~~~~~~~~~~~~
    In file included from C:/Programs/msys64/mingw64/include/windef.h:9,
                     from C:/Programs/msys64/mingw64/include/windows.h:69,
                     from ../../src/win/winmain.c:50:
    C:/Programs/msys64/mingw64/include/minwindef.h:196:28: note: 'FARPROC' declared here
      196 |   typedef INT_PTR (WINAPI *FARPROC) ();
          |                            ^~~~~~~
    make: *** [Makefile:679: winmain.o] Error 1
    
     
    • Ethan Merritt

      Ethan Merritt - 2025-05-08

      Ugh. One more try. If this one doesn't work I will have to leave it to someone more familiar with Windows programming.

       
  • Tatsuro MATSUOKA

    The 2nd patch solves the issue. Thanks!

     
  • Ethan Merritt

    Ethan Merritt - 2025-05-15
    • status: open --> pending-fixed
    • Group: -->
    • Priority: -->
     
  • Ethan Merritt

    Ethan Merritt - 2025-06-04
    • Status: pending-fixed --> closed-fixed
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.