Targeting both 32bit and 64bit with Visual Studio in same solution/project

Yes, you can target both x86 and x64 with the same code base in the same project. In general, things will Just Work if you create the right solution configurations in VS.NET (although P/Invoke to entirely unmanaged DLLs will most likely require some conditional code): the items that I found to require special attention are: … Read more

Why is x86 ugly? Why is it considered inferior when compared to others? [closed]

Couple of possible reasons for it: x86 is a relatively old ISA (its progenitors were 8086s, after all) x86 has evolved significantly several times, but hardware is required to maintain backwards compatibility with old binaries. For example, modern x86 hardware still contains support for running 16 bit code natively. Additionally, several memory-addressing models exist to … Read more

System.BadImageFormatException: Could not load file or assembly (from installutil.exe)

Some more detail for completeness in case it helps someone… Note that the most common reason for this exception these days is attempting to load a 32 bit-specific (/platform:x86) DLL into a process that is 64 bit or vice versa (viz. load a 64 bit-specific (/platform:x64) DLL into a process that is 32 bit). If … Read more

Floating point vs integer calculations on modern hardware

For example (lesser numbers are faster), 64-bit Intel Xeon X5550 @ 2.67GHz, gcc 4.1.2 -O3 short add/sub: 1.005460 [0] short mul/div: 3.926543 [0] long add/sub: 0.000000 [0] long mul/div: 7.378581 [0] long long add/sub: 0.000000 [0] long long mul/div: 7.378593 [0] float add/sub: 0.993583 [0] float mul/div: 1.821565 [0] double add/sub: 0.993884 [0] double mul/div: … Read more

Why does Windows64 use a different calling convention from all other OSes on x86-64?

Choosing four argument registers on x64 – common to UN*X / Win64 One of the things to keep in mind about x86 is that the register name to “reg number” encoding is not obvious; in terms of instruction encoding (the MOD R/M byte, see http://www.c-jump.com/CIS77/CPU/x86/X77_0060_mod_reg_r_m_byte.htm), register numbers 0…7 are – in that order – ?AX, … Read more

Possible GCC bug when returning struct from a function

I don’t see any UB here; your types are unsigned so signed-overflow UB is impossible, and there’s nothing weird. (And even if signed, it would have to produce correct outputs for inputs that don’t cause overflow UB, like rdi=1). It’s broken with GCC’s C++ front-end as well. Also, GCC8.2 compiles it correctly for AArch64 and … Read more

How to find if a native DLL file is compiled as x64 or x86?

You can use DUMPBIN too. Use the /headers or /all flag and its the first file header listed. dumpbin /headers cv210.dll 64-bit Microsoft (R) COFF/PE Dumper Version 10.00.30319.01 Copyright (C) Microsoft Corporation. All rights reserved. Dump of file cv210.dll PE signature found File Type: DLL FILE HEADER VALUES 8664 machine (x64) 6 number of sections … Read more

Bubble sort slower with -O3 than -O2 with GCC

This is a regression in GCC11/12. GCC10 and earlier were doing separate dword loads, even if it merged for a qword store. It looks like GCC’s naïveté about store-forwarding stalls is hurting its auto-vectorization strategy here. See also Store forwarding by example for some practical benchmarks on Intel with hardware performance counters, and What are … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)