Filefn.h error during Build

Do you have a question about makefiles, a compiler or IDE you are using and need to know how to set it up for wxWidgets or why it doesn't compile but other IDE's do ? Post your questions here.
Post Reply
Slyde
Knows some wx things
Knows some wx things
Posts: 29
Joined: Mon Apr 09, 2018 11:08 pm

Filefn.h error during Build

Post by Slyde » Fri Oct 04, 2019 7:46 pm

I'm using Code::Blocks 17.12 and wxWidgets 3.1.2 using g++ 8.2.0.

I created a new wxWidgets project in C::B and ran it. During the build process I got an error:

Code: Select all

||=== Build: Debug in test-001 (compiler: GNU GCC Compiler) ===|
C:\wxWidgets-3.1.2\include\wx\filefn.h||In function 'long long int wxFtell(FILE*)':|
C:\wxWidgets-3.1.2\include\wx\filefn.h|165|error: operands to ?: have different types 'fpos_t' and 'long long int'|
||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 8 second(s)) ===|
Filefn.h immediately opens in the editor and points to line 165:

Code: Select all

return fgetpos(fp, &pos) == 0 ? pos : -1LL;
This can be fixed, right?
Windows 10 Pro
Code::Blocks 17.12 w/MinGW-w64 8.1.0

PB
Part Of The Furniture
Part Of The Furniture
Posts: 2117
Joined: Sun Jan 03, 2010 5:45 pm

Re: Filefn.h error during Build

Post by PB » Fri Oct 04, 2019 8:09 pm

If you think there is a bug, you should report on wxTrac.

If you do, make sure that you provide the necessary information about your compiler toolchain. Generally speaking, just GCC version may not be enough, you need to state the MinGW flavor (MinGW, MinGW-w64, MSYS...).

Additionally, you should provide the information about how you built wxWidgets, including the value of -std parameter in CXX flags, if any.

Finally, if the issue arises during building your application, you need to provide the relevant information there as well, to see if the build options of your program are are correct and if they are not in conflict with those used when building wxWidgets.

Slyde
Knows some wx things
Knows some wx things
Posts: 29
Joined: Mon Apr 09, 2018 11:08 pm

Re: Filefn.h error during Build

Post by Slyde » Fri Oct 04, 2019 8:30 pm

I'm not the expert here! I don't know if it's a bug or not! What do you think? I just told you all I did. Does it sound like a bug? Or something correctable, something that's been hammered on before?
Windows 10 Pro
Code::Blocks 17.12 w/MinGW-w64 8.1.0

PB
Part Of The Furniture
Part Of The Furniture
Posts: 2117
Joined: Sun Jan 03, 2010 5:45 pm

Re: Filefn.h error during Build

Post by PB » Fri Oct 04, 2019 8:37 pm

This is just a user forum where peers ask questions, discuss issues and ideas related to wxWidgets. You can reach actual developers by posting in the wx-users mailing list.

If you want to know if something is a known issue, searching wxTrac / Commit list is IMO much better idea.

Additionally, not knowing all the information I asked in the previous post, it is impossible to tell if the issue is in your settings or really in wxWidgets.


FWIW, with mingw-w64 i686-8.1.0-posix-dwarf-rt_v6-rev0 (GCC 8.1) and wxWidgets built with

Code: Select all

mingw32-make -f makefile.gcc BUILD=debug CXXFLAGS="-std=c++17"
A test application in Code::Blocks project with correct settings, containing this code

Code: Select all

FILE* f = wxFopen("d:\\dev\\a.txt", "r");
long long pos = wxFtell(f);
builds and runs just fine on my Windows 10 computer.

EDIT
AFAICT, the error described in the OP manifests only in the code guarded by wxNEEDS_STRICT_ANSI_WORKAROUNDS.
wxNEEDS_STRICT_ANSI_WORKAROUNDS is defined only for traditional MinGW (and not e.g. for MinGW-w64 or TDM-GCC) which lacks certain POSIX functions. I used MinGW-w64 so the issue could not be reproduced.
Last edited by PB on Fri Oct 04, 2019 9:01 pm, edited 3 times in total.

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 3700
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Filefn.h error during Build

Post by ONEEYEMAN » Fri Oct 04, 2019 8:42 pm

Hi,
How did you build wxWidgets and what options did you supply to C::B wizard?

Thank you.

Slyde
Knows some wx things
Knows some wx things
Posts: 29
Joined: Mon Apr 09, 2018 11:08 pm

Re: Filefn.h error during Build

Post by Slyde » Sun Oct 06, 2019 2:21 pm

Thanks, PB.
I know just enough abt C++ to be 110% dangerous. Truth is, your last post showed me how to set the flags to ensure wxWidgets were compiled to use C++17 standards. So that was cool for me. But, it did me no good. Let me explain.

I was using MinGW-w64 8.2.0. I tried all day yesterday to get wxWidgets compiled so I cld use them in C::B. All the compilations went fine. No problems. But when I'd get to C::B, it'd all fall apart with various errors. This was all with BUILD=debug. So late last night, I removed everything and started over for the 6th or 7th time. This time, I got the same compiler as you used. And did another debug build. Same damn thing again. So I wiped it out, watched two youtube vids on this and then came back and did a release build. Cranked up C::B and compiled a and ran the naked form. After I cried from happiness for 10 minutes, I added a few buttons and ran it again. No issues. So I'm not sure why I cldn't get a debug build to work. I did it just as you did. Then I did it with adding BUILD=debug. It was still broken.

Thank you for showing me how to use the command line to set those flags:

Code: Select all

CXXFLAGS="-std=c++17"
I have another question, but I'll open a new post for that.


ONEEYEMAN: Thanks for offering to help.
Windows 10 Pro
Code::Blocks 17.12 w/MinGW-w64 8.1.0

PB
Part Of The Furniture
Part Of The Furniture
Posts: 2117
Joined: Sun Jan 03, 2010 5:45 pm

Re: Filefn.h error during Build

Post by PB » Sun Oct 06, 2019 2:28 pm

Is there a reason why are you using classical MinGW? It has been known to have issues with wxWidgets (or vice versa) for long time.

wxWidgets do not use it for official builds either. If you do not need GCC 8.2 and 8.1 would be OK, I would suggest using mingw-w64 instead of classical MinGW.

Slyde
Knows some wx things
Knows some wx things
Posts: 29
Joined: Mon Apr 09, 2018 11:08 pm

Re: Filefn.h error during Build

Post by Slyde » Sun Oct 06, 2019 2:44 pm

PB: I guess I wasn't clear. Sorry for that. I said I got the same compiler as you. Here's the info from Windows:

Code: Select all

C:\Users\lands>gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=C:/MinGW/mingw32/bin/../libexec/gcc/i686-w64-mingw32/8.1.0/lto-wrapper.exe
Target: i686-w64-mingw32
Configured with: ../../../src/gcc-8.1.0/configure --host=i686-w64-mingw32 --build=i686-w64-mingw32 --target=i686-w64-mingw32 --prefix=/mingw32 --with-sysroot=/c/mingw810/i686-810-posix-dwarf-rt_v6-rev0/mingw32 --enable-shared --enable-static --disable-multilib --enable-languages=c,c++,fortran,lto --enable-libstdcxx-time=yes --enable-threads=posix --enable-libgomp --enable-libatomic --enable-lto --enable-graphite --enable-checking=release --enable-fully-dynamic-string --enable-version-specific-runtime-libs --disable-sjlj-exceptions --with-dwarf2 --disable-libstdcxx-pch --disable-libstdcxx-debug --enable-bootstrap --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-gnu-as --with-gnu-ld --with-arch=i686 --with-tune=generic --with-libiconv --with-system-zlib --with-gmp=/c/mingw810/prerequisites/i686-w64-mingw32-static --with-mpfr=/c/mingw810/prerequisites/i686-w64-mingw32-static --with-mpc=/c/mingw810/prerequisites/i686-w64-mingw32-static --with-isl=/c/mingw810/prerequisites/i686-w64-mingw32-static --with-pkgversion='i686-posix-dwarf-rev0, Built by MinGW-W64 project' --with-bugurl=https://sourceforge.net/projects/mingw-w64 CFLAGS='-O2 -pipe -fno-ident -I/c/mingw810/i686-810-posix-dwarf-rt_v6-rev0/mingw32/opt/include -I/c/mingw810/prerequisites/i686-zlib-static/include -I/c/mingw810/prerequisites/i686-w64-mingw32-static/include' CXXFLAGS='-O2 -pipe -fno-ident -I/c/mingw810/i686-810-posix-dwarf-rt_v6-rev0/mingw32/opt/include -I/c/mingw810/prerequisites/i686-zlib-static/include -I/c/mingw810/prerequisites/i686-w64-mingw32-static/include' CPPFLAGS=' -I/c/mingw810/i686-810-posix-dwarf-rt_v6-rev0/mingw32/opt/include -I/c/mingw810/prerequisites/i686-zlib-static/include -I/c/mingw810/prerequisites/i686-w64-mingw32-static/include' LDFLAGS='-pipe -fno-ident -L/c/mingw810/i686-810-posix-dwarf-rt_v6-rev0/mingw32/opt/lib -L/c/mingw810/prerequisites/i686-zlib-static/lib -L/c/mingw810/prerequisites/i686-w64-mingw32-static/lib -Wl,--large-address-aware'
Thread model: posix
gcc version 8.1.0 (i686-posix-dwarf-rev0, Built by MinGW-W64 project)
It may not be exactly as yours, but I think it's close. But if it's the wrong one, then that wld explain a thing or two.
Windows 10 Pro
Code::Blocks 17.12 w/MinGW-w64 8.1.0

Post Reply