8
c:\...random.h|106|error: expected unqualified-id before '__int128'

When I'm compiling a 32 bit program, the above is the error I get. I'm using http://sourceforge.net/projects/mingwbuilds/

Why? My code compiled fine with 4.7.2 but I wanted to update to 4.8 for the bug fixes and it gets rid of the 0 used as null value for pointer warnings when there are no zeros.

Many of the bug fixes I want. It compiles my x64 ones just fine on Windows.

Is there a way to get it to compile x32 applications?

wallyk
  • 56,922
  • 16
  • 83
  • 148
Brandon
  • 22,723
  • 11
  • 93
  • 186
  • 1
    Short answer is no. `__int128` is meant for 64-bit systems. – Mysticial Mar 31 '13 at 00:48
  • :S But my code doesn't use __int128. The compiler can compile both x32 and x64 :S The highest type I used was std::uint32_t and std::size_t – Brandon Mar 31 '13 at 00:49
  • 3
    Oh... sounds like your installation is borked then. – Mysticial Mar 31 '13 at 00:50
  • 1
    Then you'll probably need to edit G++'s headers to guard against using 128-bits on 32-bit builds, and / or report this to mingw as a bug. – Rup Mar 31 '13 at 00:50
  • I suggest using the standard `int128_t` (from `inttypes.h` or `cinttypes`, not that `int128_t` is required to exist, either), rather than the compiler-specific __int128. Don't use a C++ compiler to compile C code; Use a C compiler, and link the resulting object code into your C++ projects. This way, you won't get warnings and errors as a result of compiling C code in a C++ compiler (eg. `char *foo = malloc(0);`). *edit*: Disregard this. I really should read the comments before writing my own :/ – autistic Mar 31 '13 at 01:10
  • 1
    Can you show us a minimal source file that exhibits the problem? Or does it do this with *all* source files? – Keith Thompson Mar 31 '13 at 02:04
  • 2
    @Rup: I'd be very hesitant to edit system headers. – Keith Thompson Mar 31 '13 at 02:04
  • @Keith The compile error is in a system header. (It's been edited out of the question but you can see in [revision 2](http://stackoverflow.com/revisions/15725167/2) that's a system-provided random.h.) Unless he done lots of #defines before including it, it looks to me like the system headers are broken. – Rup Mar 31 '13 at 11:44
  • @Keith To be clear, I'm suggesting he comments out the bits that don't work and works around them not being there as opposed to make up his own whole new bits of system headers. I doubt he needs max-2^128 random numbers. – Rup Mar 31 '13 at 11:58
  • Actually, that's a fair point: are you #including `` before ``? Try putting all the MinGW-supplied headers first in your include order. – Rup Mar 31 '13 at 11:59
  • I tried commenting them out and I haven't ever used random.h. I did: #include which uses random.h and it throws that error. Commenting out the bits isn't an option because it goes into a world of trouble after that. I just decided to go back to 4.7.2 :( Thank you guys for all the replies and suggestions. – Brandon Mar 31 '13 at 18:24
  • @Rup: Most of the time when someone thinks there's a bug in the compiler (or more broadly, the implementation, including compiler, libraries, and system headers), it's a bug in their own code. Most of the remaining time when it isn't a bug in their own code, the problem is that the compiler was installed incorrectly. If this is one of those rare cases of an actual bug in a system header, be sure to save copies the original headers before trying to modify them. – Keith Thompson Mar 31 '13 at 19:16
  • @Keith OK, but this compiler distribution is unzip-to-install. I can reproduce the problem with the download from the question: you just need to try and compile `#include ` using `g++ -m32 test.cpp`. – Rup Apr 01 '13 at 01:08
  • What header is this from? Random.h? Can you show more of your makefile? – Jared Burrows Dec 23 '13 at 20:23

1 Answers1

7

__int128 is protected by

!defined(STRICT_ANSI) && defined(_GLIBCXX_USE_INT128)

So, you could either use -ansi (in case your code is strictly ansi c++ complaint), I faced errors in linker due to the fact that the linker unable to find the 32bit libs.

_GLIBCXX_USE_INT128

is defined in "lib/gcc/x86_64-w64-mingw32/4.8.1/include/c++/x86_64-w64-mingw32/bits/c++config.h" which I am pretty sure was generated by the autoconfigure based on the system the tool chains are built.

You better download the 32bit version on mingw gcc (binary) package and install them too.

Sundar
  • 469
  • 3
  • 8