Author Topic: Windows 11: pointer size varies depending on computer  (Read 527 times)

Offline alfredo

  • Single posting newcomer
  • *
  • Posts: 6
Windows 11: pointer size varies depending on computer
« on: October 22, 2025, 11:49:46 am »
Hi,
I have a strange, at least for me, behavior with windows 11 25H2 64 bit, codeblock 25.03 with gcc 14.2.0 64 bit compiler and pointer.
The code is very simple:

Code
#include <iostream>

using namespace std;

int main()
{
    cout << sizeof(int *) << endl;

    return 0;
}

The output is 4 byte on i5-10400 CPU that is wrong whereas is 8 byte on i5-11400 and various ryzen CPUs that is correct.
I tried to copy the same project into the different machines and I had problem only with the first one.
If I manually force -m 64 on the first machine, I get sorry, unimplemented: 64-bit mode not compiled in.. Then I have to manually set on build option minGW64 compiler instead of GCC and it works with -m 64, but it does with default settings.
What could be the reason for this?
Thank you

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1787
Re: Windows 11: pointer size varies depending on computer
« Reply #1 on: October 22, 2025, 01:10:14 pm »
Code::Blocks is an IDE, any concerns related to compilers should be dealt with in their respective support pages.

Offline alfredo

  • Single posting newcomer
  • *
  • Posts: 6
Re: Windows 11: pointer size varies depending on computer
« Reply #2 on: October 22, 2025, 10:35:38 pm »
Code::Blocks is an IDE, any concerns related to compilers should be dealt with in their respective support pages.

Correct, but in this case it is an issue with the IDE not configuring the compiler settings correctly.

Offline nenin

  • Almost regular
  • **
  • Posts: 242
Re: Windows 11: pointer size varies depending on computer
« Reply #3 on: Yesterday at 07:27:58 am »
Code::Blocks is an IDE, any concerns related to compilers should be dealt with in their respective support pages.

Correct, but in this case it is an issue with the IDE not configuring the compiler settings correctly.
It is not a problem of IDE. In case of MinGW you need to have different installations for 32 and 64 bits compiler and select one you want to use in project.
C::B allows to have multiply targets in one project and build them with different compilers, but you have to configure it properly.

Offline alfredo

  • Single posting newcomer
  • *
  • Posts: 6
Re: Windows 11: pointer size varies depending on computer
« Reply #4 on: Yesterday at 10:17:05 am »
Code::Blocks is an IDE, any concerns related to compilers should be dealt with in their respective support pages.

Correct, but in this case it is an issue with the IDE not configuring the compiler settings correctly.
It is not a problem of IDE. In case of MinGW you need to have different installations for 32 and 64 bits compiler and select one you want to use in project.
C::B allows to have multiply targets in one project and build them with different compilers, but you have to configure it properly.

Okay. Can you explain why the same project created on the latest version of Codeblock on Windows 11 25H2 works fine on some computers but not on others, and I have to manually change the compiler? The settings are the same. In my opinion, it has something to do with Codeblock and its integrated mingw compiler.

Offline nenin

  • Almost regular
  • **
  • Posts: 242
Re: Windows 11: pointer size varies depending on computer
« Reply #5 on: Yesterday at 12:21:24 pm »

Okay. Can you explain why the same project created on the latest version of Codeblock on Windows 11 25H2 works fine on some computers but not on others, and I have to manually change the compiler? The settings are the same. In my opinion, it has something to do with Codeblock and its integrated mingw compiler.

"project" means  "software project in C::B" or exe file, generatated by mingw gcc using C::B?
At that moment I can only suspect that you somehow installed on one PC 32b version from here: https://sourceforge.net/projects/codeblocks/files/Binaries/25.03/Windows/32bit/
 
« Last Edit: Yesterday at 12:38:14 pm by nenin »

Offline alfredo

  • Single posting newcomer
  • *
  • Posts: 6
Re: Windows 11: pointer size varies depending on computer
« Reply #6 on: Yesterday at 01:03:08 pm »

Okay. Can you explain why the same project created on the latest version of Codeblock on Windows 11 25H2 works fine on some computers but not on others, and I have to manually change the compiler? The settings are the same. In my opinion, it has something to do with Codeblock and its integrated mingw compiler.

"project" means  "software project in C::B" or exe file, generatated by mingw gcc using C::B?
At that moment I can only suspect that you somehow installed on one PC 32b version from here: https://sourceforge.net/projects/codeblocks/files/Binaries/25.03/Windows/32bit/

Right, a Codeblocks project with the code in the first post. You can compile it yourself on another computer (I can share it). No, I am 99.99% sure that I installed 64-bit Mingw bundled with Codeblocks. In fact, if I manually change the compiler settings, I can compile it correctly. My question is: why does the same project created and used by the same version of software and compiler behave differently on different machines with the same Windows 11 25H2 64-bit?
Moreover, why in such machine I have to manually setup the compiler to mingw 64 bit and compile with -m 64?
Thank you

Offline nenin

  • Almost regular
  • **
  • Posts: 242
Re: Windows 11: pointer size varies depending on computer
« Reply #7 on: Yesterday at 01:24:59 pm »
"sizeof(int*)==4"  means that you somehow generated 32b code. It is not dependent on C::B, by default C::B uses default compiler, and the choice of the compiler options is not affected by this selection. It may be OK for exact compiler or may be wrong. For example, if you put something like "-march=x86-64-v2" for 32b compiler, it will be unhappy. Check name of compiler in project options on top of the dialog. If it is something like "GCC MINGW64" - it should be 64b,  if "GCC MINGW" or "GCC MINGW32" - 32b.
« Last Edit: Yesterday at 01:30:17 pm by nenin »

Offline alfredo

  • Single posting newcomer
  • *
  • Posts: 6
Re: Windows 11: pointer size varies depending on computer
« Reply #8 on: Yesterday at 02:19:46 pm »
"sizeof(int*)==4"  means that you somehow generated 32b code. It is not dependent on C::B, by default C::B uses default compiler, and the choice of the compiler options is not affected by this selection. It may be OK for exact compiler or may be wrong. For example, if you put something like "-march=x86-64-v2" for 32b compiler, it will be unhappy. Check name of compiler in project options on top of the dialog. If it is something like "GCC MINGW64" - it should be 64b,  if "GCC MINGW" or "GCC MINGW32" - 32b.

That's clear. Can you explain why, on three different machines, with the same Windows 11 25H2 64 bit, the same Codeblocks 25.03 64 bit, and therefore the same mingw (GCC) compiler, with the same project (no copied and pasted code), I have to manually change the compiler from GCC to mingw64 only for the third machine?
  • intel i5-11400 ok
  • ryzen 7 7840u ok
  • i5-10400 I have to change the settings

For me this is strange. What could be the reason?
Thank you

Offline nenin

  • Almost regular
  • **
  • Posts: 242
Re: Windows 11: pointer size varies depending on computer
« Reply #9 on: Yesterday at 02:56:13 pm »

That's clear. Can you explain why, on three different machines, with the same Windows 11 25H2 64 bit, the same Codeblocks 25.03 64 bit, and therefore the same mingw (GCC) compiler, with the same project (no copied and pasted code), I have to manually change the compiler from GCC to mingw64 only for the third machine?
  • intel i5-11400 ok
  • ryzen 7 7840u ok
  • i5-10400 I have to change the settings
For me this is strange. What could be the reason?
Thank you
I cannot explain you this strange observation. I never faced these or similar problems, but I've never used a C::B distribution with a compiler. I`m using C::B now with 3 compilers ( 64b gcc 14.2, 32b gcc 14.2 and 32b for XP gcc 9.3) and C::B always keeps proper compiler in project, if this compiler is actually is installed. If compiler is not installed, strange things may happen, but not the one you described.

Offline gd_on

  • Lives here!
  • ****
  • Posts: 830
Re: Windows 11: pointer size varies depending on computer
« Reply #10 on: Yesterday at 04:15:13 pm »
Quote
I have to manually change the compiler from GCC to mingw64 only for the third machine?

For me this is strange. What could be the reason?

Probably (or May be), on your 3rd config, there was already a 32b compiler installed somewhere. So, when you installed C::B, it's installer has detected this compiler and configurated it as the default one, instead of the compiler distributed with C::B. This could explain why you had to change manually the configuration and why it compiled before your changes.
Windows 11 64 bits (25H2), svn C::B (last version or almost!), wxWidgets 3.3.1, Msys2 Compilers 15.2.0, 64 bits (seh, posix : gcc, g++ and gfortran in C:\msys64\mingw64) or 32 bits (dwarf2, posix  in C:\msys64\mingw32).

Offline Krice

  • Almost regular
  • **
  • Posts: 175
Re: Windows 11: pointer size varies depending on computer
« Reply #11 on: Yesterday at 05:42:03 pm »
If I manually force -m 64 on the first machine, I get sorry, unimplemented: 64-bit mode not compiled in..

The -m64 is not "manually forcing" anything, you set it to compile 64 bit programs. If the compiler doesn't support it you may get an error like that. Also, if you use sizeof properly the pointer size doesn't matter, whatever it might be.

Offline alfredo

  • Single posting newcomer
  • *
  • Posts: 6
Re: Windows 11: pointer size varies depending on computer
« Reply #12 on: Yesterday at 09:39:27 pm »
Quote
I have to manually change the compiler from GCC to mingw64 only for the third machine?

For me this is strange. What could be the reason?

Probably (or May be), on your 3rd config, there was already a 32b compiler installed somewhere. So, when you installed C::B, it's installer has detected this compiler and configurated it as the default one, instead of the compiler distributed with C::B. This could explain why you had to change manually the configuration and why it compiled before your changes.

I am sure that there is only codeblocks 25.03 mingw 64 bit version. I triple checked :)

If I manually force -m 64 on the first machine, I get sorry, unimplemented: 64-bit mode not compiled in..

The -m64 is not "manually forcing" anything, you set it to compile 64 bit programs. If the compiler doesn't support it you may get an error like that. Also, if you use sizeof properly the pointer size doesn't matter, whatever it might be.

A 64 bit compiler on 64 bit OS should compile 64 bit binary by default.
« Last Edit: Yesterday at 09:41:57 pm by alfredo »