The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,862 other subscribers

Archive for the ‘C++’ Category

How to: Set a Thread Name in Native Code

Posted by jpluimers on 2016/06/15

This is what the Delphi [WayBack] System.Classes.TThread.NameThreadForDebugging (introduced in Delphi 2010) is based on:

//
// Usage: SetThreadName (-1, "MainThread");
//
#include <windows.h>
const DWORD MS_VC_EXCEPTION=0x406D1388;

#pragma pack(push,8)
typedef struct tagTHREADNAME_INFO
{
   DWORD dwType; // Must be 0x1000.
   LPCSTR szName; // Pointer to name (in user addr space).
   DWORD dwThreadID; // Thread ID (-1=caller thread).
   DWORD dwFlags; // Reserved for future use, must be zero.
} THREADNAME_INFO;
#pragma pack(pop)

void SetThreadName( DWORD dwThreadID, char* threadName)
{
   THREADNAME_INFO info;
   info.dwType = 0x1000;
   info.szName = threadName;
   info.dwThreadID = dwThreadID;
   info.dwFlags = 0;

   __try
   {
      RaiseException( MS_VC_EXCEPTION, 0, sizeof(info)/sizeof(ULONG_PTR), (ULONG_PTR*)&info );
   }
   __except(EXCEPTION_EXECUTE_HANDLER)
   {
   }
}

Related:

For Delphi 2009 and 2007: It is implemented in the SetThreadName method of the IdGlobal unit.

–jeroen

Posted in C++, Delphi, Development, Software Development | Leave a Comment »

The huge Borland C++ Box

Posted by jpluimers on 2016/03/09

I never had the box, but someone is selling the [Wayback] 10+ kg Borland C++ 3.0 box:

The 10+ kg Borland C++ 3.0 box

image

Edit 2022-02-04: the above went away because of link rot, so I replaced it with an Archive.is version as it was copied at [Wayback/Archive.is] My First Windows C++ Application in Ages: Hello World in Win32 with Visual C++ 2010 – Pete Brown’s 10rem.net.

I did a bit of digging ([Wayback/Archive.is] borland c++ box – Google Search) and found [Wayback/Archive.is] Version information for older Borland/Inprise C Compilers has all the product box photos of these products:

Borland C++ 3.1 through 4.5 shipped in huge boxes, each even larger than the before it.

The box with the 1994 Borland C++ 4.5 and Database Tools supported DOS, Windows, and Win32. It had either a CD or 28 3.5″ HD diskettes.

The last version with 5.25″ diskettes was the 1991 Borland C++ 3.1: 15-5.25″ 1.2 Meg. Diskettes or 15 3.5″ 1.44MB disks.

Borland C++ 3.1 and Application Frameworks

–jeroen

Posted in Borland C++, C++, Development, Software Development | 2 Comments »

On Epsilon, MachineEpsilon, and relative differences – via: I was wondering, that what is the closest value to the Zero floating point can have – G+

Posted by jpluimers on 2015/10/07

A long time ago, there was an interesting discussion here: I was wondering, that what is the closest value to the Zero floating point can have.

Recently I needed to do some calculations on series where getting close to zero could become a problem.

  • Math seems to have an Epsilon of 1E-12.
  • Sytem.Types has Epsilon of 1E-30 and Epsilon2 of 1E-40.
  • XE4+ FMX has IsEssentiallyZero and IsNotEssentiallyZero for Single values.

In practice it depends a lot on what you are doing. Sometimes absolute Epsilons are best, but at other times relative difference is much more applicable.

Then there is also a Machine Epsilon: a way to derive an Epsilon from a data type that works in all languages and platforms.

–jeroen

Posted in .NET, Algorithms, C, C#, C++, Delphi, Development, Floating point handling, Software Development | 1 Comment »

Rudy’s Delphi Corner – Pitfalls of converting, on converting from C/C++ to Delphi

Posted by jpluimers on 2015/09/02

If ever in need to translate C/C++ headers or code to Delphi, this refernece by Rudy Velthuis – a dentist with a strong interest in programming – is the best I could find: Rudy’s Delphi Corner – Pitfalls of converting.

It is written in a pretty version agnostic way, and covers the vast majority of conversion topics.

And it has been updated over time numerous times.

–jeroen

Posted in Borland C++, C, C++, C++ Builder, Delphi, Delphi 2005, Delphi 2006, Delphi 2007, Delphi 2009, Delphi 2010, Delphi 7, Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Delphi XE5, Delphi XE6, Delphi XE7, Delphi XE8, Development, Software Development | 10 Comments »

Windows Kernel object names are optional. Don’t give them a name unless you intend them to be shared. (via: The Old New Thing)

Posted by jpluimers on 2015/07/01

Very interesting:

Kernel object names are optional. Don’t give them a name unless you intend them to be shared.

–jeroen

via: [WayBackYou can name your car, and you can name your kernel objects, but there is a qualitative difference between the two – The Old New Thing – Site Home – MSDN Blogs.

Posted in .NET, C, C++, Delphi, Development, Software Development, The Old New Thing, Windows Development | Leave a Comment »

2 More Old Micro Cornucopia issues on BitSavers from 1986 « The Wiert Corner – irregular stream of stuff

Posted by jpluimers on 2015/06/18

Almost two years ago, I wrote “the only issues missing are #28, #30 and #31.”. As of mid May any more:

All of them are from the 5th anniversary year.

–jeroen

via 2 More Old Micro Cornucopia issues on BitSavers from 1986 « The Wiert Corner – irregular stream of stuff.

Posted in 6502 Assembly, Assembly Language, BitSavers.org, C, C++, Development, History, Pascal, Software Development, Turbo Pascal | Leave a Comment »

RosettaCode: cool way to improve your coding skills

Posted by jpluimers on 2015/01/22

Wow: I feel like having lived under a stone for 8 years, as RosettaCode has been alive since it was founded in 2007 by Mike Mol.

The idea is that you solve a task and learn from that, or learn by seeing how others have solved tasks or draft tasks.

So in a sense it is similar to the Rosetta stone: it has different languages phrasing the same tasks.

There are already a whole bunch of languages on RosettaCode (of which a few are in the categories below), and you can even suggest or add your own languages.

When you want to solve tasks, be sure to look at the list unimplemented tasks by language that leads to automatic reports by language (for instance two of the languages I use most often: C# and Delphi).

I’m sure there are lots of programming chrestomathy sites, even beyond the ones, and it feels very similar to programming kata sites.

–jeroen

Posted in .NET, APL, Awk, bash, Batch-Files, C, C#, C++, COBOL, CommandLine, Delphi, Development, Fortran, FreePascal, Java, JavaScript/ECMAScript, Lazarus, Object Pascal, Office VBA, Pascal, Perl, PHP, PowerShell, PowerShell, Prism, Scripting, sed script, Sh Shell, Software Development, Turbo Prolog, VB.NET, VBS, VBScript, Visual Studio and tools, Web Development | Leave a Comment »

Windows software developers – High DPI awareness: the developer Y2K (or is it EUR introduction) of our time.

Posted by jpluimers on 2014/11/05

An interesting statement by Steve Maughan:

Looking at how many High DPI awareness or lack of is the developers Y2K of our time.

Looking at the trouble Windows and Windows applications in general have with High DPI (more in general: resolution independence). I think it rates even higher: as the EUR introduction problem of our time.

What do you think?

–jeroen

via High DPI awareness is must have feature for XE8. Not only for Delphi IDE, but….

Posted in .NET, C++, Delphi, Development, Software Development, WPF | 12 Comments »

When deadlocks become livelocks (via: Do deadlocks cause high CPU utilization? – Stack Overflow)

Posted by jpluimers on 2014/08/20

Depending on how you organize locks (for instance via waiting on semaphores or mutexes or spinlocks), deadlocks can become livelocks:

Inability to make forward progress because of conflicting spinlocks is usually referred to as ‘livelock’.

Thanks to Martin James for reminding me of that and Danny Thorpe for describing different ways of locking.

Be sure to read on deadlock prevention as well.

–jeroen

via: c++ – Do deadlocks cause high CPU utilization? – Stack Overflow.

Posted in .NET, C++, Delphi, Development, Software Development | Leave a Comment »

Windows Explorer – copying path/name of files and folders (full/short; regular/UNC; unix/cygwin): Path Copy Copy – Home

Posted by jpluimers on 2014/04/11

This Explorer extension is brilliant: Path Copy Copy – Home.

It works in Windows XP and up (including 7, 8 .x, 20xx Server, etc).

The Open Source is done in Visual Studio with C++.

–jeroen

Read the rest of this entry »

Posted in C++, Development, Power User, Software Development, Visual Studio 2010, Visual Studio and tools, Windows, Windows 7, Windows 8, Windows 8.1, Windows Server 2003, Windows Server 2003 R2, Windows Server 2008, Windows Server 2008 R2, Windows Vista, Windows XP | Leave a Comment »