C++ Template Inheritance and Copy Construction: A Puzzling static_assert

2025-06-10
C++ Template Inheritance and Copy Construction: A Puzzling static_assert

This article explores a puzzling issue regarding copy constructors in C++ template inheritance. The `Derived` class inherits from `Base`, where `Base`'s copy constructor is deleted. However, `Derived` defines its own copy constructor. Even though this constructor attempts to copy the uncopyable `Base` object, `std::is_copy_constructible` still returns true. This is because the compiler only checks for the presence of a non-deleted copy constructor, not its instantiability. The author further discusses the differences between explicitly defined and implicitly defined copy constructors, and the implications of moving the copy constructor definition out of line.

Read more
Development Copy Construction

Run C# Code Directly Without Project Files: .NET 10 Preview 4

2025-05-29
Run C# Code Directly Without Project Files: .NET 10 Preview 4

.NET 10 Preview 4 introduces a game-changing feature: you can now run C# files directly using `dotnet run app.cs`—no project file or scaffolding needed! This significantly lowers the barrier to entry for C#, making it ideal for learning, prototyping, or quick scripts. Leverage powerful file-level directives like `#:package`, `#:sdk`, and `#:property` to manage NuGet packages, SDKs, and MSBuild properties directly within your .cs file, all while maintaining compatibility with existing MSBuild concepts. Even as your script grows into a full application, seamless conversion to a project-based app is supported. This streamlined workflow simplifies the C# development experience, making it incredibly approachable and convenient for CLI utilities, automation scripts, and more.

Read more
Development file-based apps

Windows 11 Gets a New Built-in Command-Line Text Editor: Edit

2025-05-19
Windows 11 Gets a New Built-in Command-Line Text Editor: Edit

Microsoft introduces Edit, a new lightweight command-line text editor for 64-bit Windows. This open-source editor, under 250KB, boasts features like mouse support, multiple file opening, find and replace, word wrap, and crucially, a modeless design to avoid the steep learning curve of modal editors like Vim. It'll preview in the Windows Insider Program in the coming months before becoming a standard part of Windows 11.

Read more
Development command-line editor

Nostalgic MS-DOS Icons: More Useful Than Program Manager?

2025-05-16
Nostalgic MS-DOS Icons: More Useful Than Program Manager?

A user shared their perspective on a set of MS-DOS icons, arguing they're more practical than the Program Manager's default set. Examples include icons for Microsoft Basic Compiler, Microsoft Project, and Close-Up 4.0, highlighting their historical usage. The author points out design flaws like outdated MS-DOS logos or inappropriate overlays. This sparks a discussion about early software UI design and nostalgia.

Read more
Misc

Windows 7 Login Delay Mystery: Solid Color Backgrounds Are the Culprit?

2025-04-29
Windows 7 Login Delay Mystery: Solid Color Backgrounds Are the Culprit?

The author, a long-time user of solid color backgrounds since Windows 95, discovered a 30-second delay on the Windows 7 welcome screen when using a solid color wallpaper. This isn't a longer login time, but rather a timeout triggered when the system waits for a signal indicating wallpaper loading completion. Solid color backgrounds, lacking bitmap information, prevent this signal from being sent. A similar issue exists with the "Hide desktop icons" group policy, where a coding error prevents the ready signal from being sent. Microsoft fixed this in Windows 7 a few months after its release. The author also explains their preference for default settings, simplifying bug reporting and resolution.

Read more
Development System Performance

Never Suspend a Thread in Your Own Process!

2025-04-15
Never Suspend a Thread in Your Own Process!

A customer encountered a long-standing, low-frequency hang: their UI thread called into the kernel and simply hung. The kernel dump couldn't show a user-mode stack trace because the stack had been paged out. Investigation revealed a watchdog thread periodically suspending the UI thread to capture stack traces, but this time it hung for over five hours. The root cause: a deadlock. The watchdog thread, attempting to get a stack trace, needed a function table lock, but the UI thread was suspended, holding the lock. The article emphasizes never suspending a thread within its own process, as it risks deadlocks due to resource contention. To suspend a thread and capture its stack, do so from another process to avoid deadlocks.

Read more

The Mystery of the Passive USB-to-PS/2 Mouse Adapter

2025-03-28
The Mystery of the Passive USB-to-PS/2 Mouse Adapter

Early USB mice often included a green adapter to convert the USB Type-A plug to PS/2. This wasn't a smart adapter; it was purely mechanical, with no circuitry. The mouse itself did the conversion, detecting the signal type (USB or PS/2) and adjusting accordingly. It's analogous to a simple power adapter – the intelligence resides in the device, not the adapter. So, if you find one of these, remember it's just a physical connector; the actual conversion happens within the dual-bus mouse.

Read more
Hardware Mouse Adapter

Debugging a Race Condition: The RtlRunOnceExecuteOnce Trap

2025-03-23
Debugging a Race Condition: The RtlRunOnceExecuteOnce Trap

A colleague encountered a tricky concurrency issue during a weekly debug session: a critical section failed to prevent two threads from entering the same code block, leading to a `TraceLoggingRegister` double-registration failure. Deep debugging revealed the root cause: the initialization function `InitializeCriticalSectionOnce` for `RtlRunOnceExecuteOnce` incorrectly returned `STATUS_SUCCESS` (0). This led `RtlRunOnceExecuteOnce` to believe initialization failed, causing it to re-initialize the critical section on every call, triggering the race condition. The solution was to change the return value to `TRUE`, or more elegantly, replace `CRITICAL_SECTION` with `SRWLOCK`. This case highlights how subtle return value errors can lead to severe consequences and underscores the importance of choosing the appropriate synchronization primitive.

Read more
Development

TypeScript Native Compiler: 10x Performance Boost

2025-03-11
TypeScript Native Compiler: 10x Performance Boost

The TypeScript team announced a native port of the TypeScript compiler and tools to dramatically improve performance. This native implementation is projected to drastically speed up editor startup, reduce most build times by 10x, and substantially reduce memory usage. Initial testing shows compilation speed improvements of more than 10x for several large projects (e.g., VS Code, Playwright). Future native TypeScript (planned as TypeScript 7) will support more advanced refactorings, deeper code analysis, and lay the foundation for next-gen AI development tools. TypeScript 6 (JS-based) will continue to be maintained to ensure a smooth transition.

Read more

Subtle C++/WinRT Invoke Issue and its Fix

2025-03-09
Subtle C++/WinRT Invoke Issue and its Fix

A C++/WinRT pull request fixed an ambiguity in `winrt::impl::promise_base::set_completed`'s call to `invoke`, caused by Argument-dependent Lookup (ADL). The upgrade to C++20 coroutines expanded the ADL search space, unexpectedly finding `std::invoke` instead of the intended `winrt::impl::invoke`. The article details the ADL mechanism and provides a patch for older C++/WinRT versions: declaring a better-matching `invoke` function in the `winrt::Windows::Foundation` namespace to guide the compiler. This patch also includes a static assertion to ensure it's automatically removed after upgrading C++/WinRT.

Read more
Development

The 'Other' Trap in Enums: Version Compatibility and Open Enums

2025-03-02
The 'Other' Trap in Enums: Version Compatibility and Open Enums

This article discusses the pitfalls of using an 'Other' value (e.g., WidgetFlavor::Other) in C++ enums. Adding new enum values presents a challenge: how to handle them and maintain compatibility with older code versions. The author suggests avoiding 'Other' altogether and declaring the enum as open-ended, letting programs handle unrecognized values independently. This elegantly solves version compatibility issues, preventing confusion when adding new enum values and ensuring smooth transitions between old and new code.

Read more
Development Version Compatibility

Major Improvements to MSVC Address Sanitizer (ASan)

2025-02-25
Major Improvements to MSVC Address Sanitizer (ASan)

Microsoft has significantly improved the quality of MSVC Address Sanitizer (ASan). They've successfully upstreamed major parts of ASan to LLVM, enabling faster integration of improvements from the LLVM community. Furthermore, they've integrated ASan into the MSVC codebase, including the compiler, linker, and tools, allowing for memory safety issue detection in continuous integration. Visual Studio 2022 version 17.13 includes numerous fixes, reducing false positives, improving error reporting, and handling multi-process scenarios.

Read more
Development

Windows 95 Setup: The Surprisingly Complex Story of a Tiny OS

2025-02-17
Windows 95 Setup: The Surprisingly Complex Story of a Tiny OS

This article reveals the hidden complexity of the Windows 95 setup program. To create a seemingly simple installer, the team had to build a miniature operating system from scratch within MS-DOS, including graphics libraries, a window manager, multilingual support, and even compatibility with Windows 3.1. They ultimately realized it was far more efficient to use the existing Windows 3.1 runtime, avoiding massive development efforts. The story highlights the importance of code reuse in software engineering and exposes the surprisingly complex nature of the Windows 95 setup program.

Read more
Development

The 'It's Now Safe to Turn Off Your Computer' Screen: A Windows 95 Nostalgia Trip

2025-02-16
The 'It's Now Safe to Turn Off Your Computer' Screen: A Windows 95 Nostalgia Trip

Remember the 'It's now safe to turn off your computer' message in Windows 95? This story recounts a humorous anecdote on an airplane where a fellow passenger repeatedly restarted their laptop after seeing the 'Windows has been shut down' screen, not realizing they needed to manually power off the machine. This highlights the lack of power management in older computers and explains why Windows 95 included the message: a gentle reassurance that it was safe to press the power button.

Read more
Tech

USB Spec Meeting Anecdote: The Premium of Translucent Blue

2025-02-10
USB Spec Meeting Anecdote: The Premium of Translucent Blue

At a USB specification meeting, a company showcased their USB floppy drives, surprisingly offering separate versions for PCs and Macs. Committee members were puzzled, as the specification ensured the same drive worked on both systems. The representative explained that the drives were electronically identical; the only difference was the Mac version came in translucent blue plastic and cost more. This reflected the then-popular translucent plastic trend of iMacs and highlighted how some manufacturers leveraged design differences for price premiums.

Read more
Hardware floppy drive

Missile Software's 'Null Garbage Collector': Memory Leaks? Not a Problem!

2025-02-07
Missile Software's 'Null Garbage Collector': Memory Leaks?  Not a Problem!

A developer recounts a clever application of a 'null garbage collector' in missile software. Because of the limited flight time and ample hardware memory, memory leaks in the program weren't a concern. Engineers calculated the potential memory leakage during flight and added double that amount of memory to ensure the program wouldn't crash before mission completion. This approach cleverly leveraged the program's runtime constraints, effectively solving the memory leak issue—a kind of 'ultimate garbage collection'.

Read more

Go 1.24 Cryptography Overhaul: Achieving FIPS 140-3 Compliance

2025-02-06

Go 1.24 significantly refactored its cryptography packages to achieve FIPS 140-3 compliance. This is a major step forward, featuring a pure Go (and Go assembly) implementation of a FIPS 140-3 validated cryptographic module, eliminating reliance on cgo or syscalls. Microsoft Go 1.24 also updated, adding macOS preview support and enhanced Azure Linux support, but maintains its use of system libraries for cryptography, diverging from the official Go approach. New environment variables like GODEBUG=fips140=on and GOFIPS140=latest control FIPS mode; the runtime automatically enables it on FIPS-compliant systems (Azure Linux, Windows).

Read more
Development

A Hidden Teapot and Design Flaw in Windows' 3D Pipes Screensaver

2024-12-28
A Hidden Teapot and Design Flaw in Windows' 3D Pipes Screensaver

The beloved Windows 3D Pipes screensaver, known for its mesmerizing pipe animations, hides a little-known secret: a rarely appearing teapot. This teapot is a tribute to the Utah teapot, a standard reference object in computer graphics, but its incredibly low appearance rate led to user complaints about low productivity. The article also reveals that in older Windows versions, the screensaver caused high CPU usage on servers due to software rendering, recommending a black screen saver for servers instead.

Read more

C++ Compiler Errors: Nonsensical Errors from a Function Declaration

2024-12-12
C++ Compiler Errors: Nonsensical Errors from a Function Declaration

A developer adding XAML support to a C++ application encountered a series of compiler errors simply by including the winrt/Windows.UI.Xaml.h header file. The errors stemmed from what appeared to be a normal function declaration: `template struct consume_Windows_UI_Xaml_IExceptionRoutedEventArgs { [[nodiscard]] auto ErrorMessage() const; };` The root cause was a pre-existing macro named ErrorMessage in the developer's project, conflicting with the function name. This macro created an ErrorMessageString object and returned a pointer to an error message string. The macro's lack of boundaries caused the compiler to misinterpret the function declaration as a macro invocation, resulting in errors like "not enough arguments." The solution involved disabling the macro using #pragma undef before including the header or removing the macro entirely and replacing it with an inline function.

Read more