Tag Archives: C++

How to become a Windows Expert ?

This article is the continuation of How to become a Microsoft Expert? (http://netazurerangers.com/blog/comment-devenir-un-expert-microsoft/)

Windows has been Microsoft’s technological flagship for 25 years. You will tell me, yes but now there is Azure. OK but what is Azure? It is ; if I ignore the Linux part; Windows Server and Service Fabric… and that’s Windows. It’s C / C ++. And yes, again! There is no secret. it must work quickly and well. It must be reliable, robust, fast and secure.

In one of my last post “C ++ unsafe and unsecure?” (http://netazurerangers.com/blog/c-unsafe-et-unsecure/), I explain why C / C ++ is the best and why Microsoft is doing 95% of its products with. Microsoft is the # 1 company in the software industry. It’s not an advertising agency like Google or Facebook, it’s pure juice Tech. Microsoft sells Products and Services. Anyway next…

How to become a Windows expert? The question is asked. First, we learn about the operating system principles via Microsoft Docs (ex: MSDN LIbrary) on https://docs.microsoft.com/en-us/windows-hardware/drivers/kernel/overview-of-windows -components

Then, we read the passage on User mode and Kernel mode via https://docs.microsoft.com/en-us/windows-hardware/drivers/gettingstarted/user-mode-and-kernel-mode

From there, we know the basic architecture of Windows. now we attack the elements on the operating system, namely the kernel and the thread scheduler. Windows order threads, Linux order processes. These two systems do not work the same way. The Processes & Threads doc is here: https://docs.microsoft.com/en-us/windows/win32/procthread/about-processes-and-threads

Then we go to practice, how to create a thread, a process, reach the end, etc. the API doc also called reference doc is here: https://docs.microsoft.com/en-us/windows/win32/procthread/process-and-thread-reference

The easiest examples can be viewed via https://docs.microsoft.com/en-us/windows/win32/procthread/process-and-thread-functions#process-and-thread-functions and more specifically the CreateThread function: https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createthread?redirectedfrom=MSDN and its example: https://docs.microsoft.com/en-us/windows / win32 / procthread / Creating-threads

To test this, you must install Visual C ++ available in Visual Studio 2019 for example, Community Edition or Pro 30 day trial. If you received money from Santa Claus, buy the following books:

Windows via C / C ++ by Jeffrey Richter and Christophe Nasarre

Windows Internals ex-Inside Windows NT (https://docs.microsoft.com/en-us/sysinternals/learn/windows-internals)

I bought Inside Windows NT in 1992 and got the virus.

Windows is huge. It’s powerful. You read the Windows Internals book and you will have vision; you will understand how the OS works. It’s very interesting and you will have no trouble understanding new Microsoft technologies with that. Microsoft NET, CLR, BCL, it’s done with C ++ and parts of the Windows API aka Win32. Watch the code on GitHub of CoreCLR (https://github.com/dotnet/runtime)

There are urban legends that Microsoft rewrites Windows from scratch; this is for managers and IT 01. For technicians, the truth is that Windows is sitting on the same code and has been evolving for 25 years. The code is improved and regularly revised in Modern C ++. I can certify it because I have the source code of Windows NT 4, Windows 2000 and access to the latest source code of Windows 190x. The code is made in:

C for kernel and drivers
in C / C ++ for the rest.
What is Modern C ++?

automatic memory release with smart points
using the Standard Template Library (STL)
use of C ++ 11/14/17 with auto, lambdas, etc.
Windows uses COM technology a lot. A COM component is registered in the registry and is invoked via APIs (https://docs.microsoft.com/en-us/windows/win32/api/_com/)

A COM component is a class with AddRef, Release, QueryInterface and methods:

The COM component is created via CoCreateObject and the COM factory:

For more information on COM components, I made in 200x a translation of some elements of “Inside COM + Base Services”: Apartments | Threads | Apartments types | Threading for In-Proc components | Apartment and languages

For more information on COM, get your hands on Inside COM + Base Services (http://www.windowscpp.com/Books/MSPress-InsideCOMBaseServices.zip) or on docs but on docs, the doc is spartan.

201x saw Microsoft turn to open source so you can find Windows components in open source:

Windows Terminal (https://github.com/microsoft/terminal)
Windows NET CoreCLR (https://github.com/dotnet/runtime)
Do like me, study these two modules and try to contribute in GitHub. And who knows, one day, you may work for Microsoft!

Chick!

Christophe | http://www.christophepichaud.com

My Microsoft’s resolutions for 2020

Friends Softies,

(EMail sent to my old Microsoft coworkers)

Here are my good resolutions for 2020…

Let me make an announcement: I want to work again for Microsoft and more particularly for Corp. It may go through Services before, I don’t know, but I’m working on it. As I told my friends Alain and the zErics, working at Microsoft was a dream but it stopped suddenly. I would not go back on this episode and the reasons for this stop, the page is turned.
Since I’m an MVP, I’ve had access to a lot of things and it’s great. Microsoft is the number 1 software company, there’s no question about it. You are working on it and you know it. This company is magnificent, the products are nickel and especially the technology is fantastic. Who doesn’t have a passion for an SDK or a product? Our job is made of passion, laughter and tears. Today’s failures will be tomorrow’s successes.

When I read Windows code, it’s complex but it’s beautiful. C ++ code contains something that other languages ​​do not have. The Microsoft style based on COM is very special. The mix between Windows types (COM strings, VARIANT, UINT, DWORD, UNICODE LPWSTR, wchar_t and char *) and C ++ types (wstring and string) means that the code is made with several styles. We find the business code mostly made in COM components or in C ++ ISO code and the specific glue in Win32 API. Don Box said “COM is love”. That is true. A coclass of a COM component is a C ++ class. We have a class in shared_ptr mode, an ambiguous AddRef ctor, an ambiguous Release dtor, a QueryInterface cast to obtain the different interfaces (a C ++ class can implement several interfaces and can inherit from several classes unlike C # which can only inherit from d ‘only one class).

In the Windows Terminal code, there is for example the WinUI code of the frame (tabbed and Window and popup menu and menu) written in pure Windows API and XAML Islands, the code of the cmd with its char buffer engine, its interpreter and the code Ancestral Windows rewritten in modern C ++. The code is improved. It’s like a good Burgundy, it gets better over time. The C ++ 98/03 code is improved in C ++ 11/14 code and gradually this Modern C ++ makes the code nickel, it is beautiful! For example, I made a contribution with PR (pull-request accepted on June 19, 2019 https://github.com/microsoft/terminal/pull/1161) which consisted of putting a shared_ptr on a raw pointer and doing the plumbing that goes with it to play with a reference behind. The memory is released automatically via the smart pointer. It’s beautiful. There is plenty of TODO and FIXME in the code to improve the Windows legacy code. I saw that it has been 4 years since the CMD code has been refactored and improved. It may be my memory that betrays me but I think that’s it; seen in code comments. You don’t realize the power of Windows tools. The GitHub code archive for Windows Terminal (https://github.com/microsoft/terminal) alone is 9.3 MB. There are 6.3 MB of .h and .cpp files. It’s not bad already. Huge for a single individual to understand. CMD is a complex tool that goes beyond a simple dir c: \! It’s a pillar of Windows. Our system admins know this. I intend to continue to invest a little more on Windows Terminal because it is exciting. This is my first resolution.

Then there is the CoreCLR (https://github.com/dotnet/runtime) which is the NET runtime. There I put myself thoroughly because it is a part of my future that is playing on it. I will learn and potash the beast to understand how it works. The archive is 99MB and unzipped is 777MB. It’s huge but good, there are unit tests & co but good C ++ code is about 76MB in size without the tests. Suffice to say that this is huge from huge. OK Windows is 1 GB of source code but we are just talking about the Windows \ NET Framework folder mscoree.dll and company… with the DLLs of the BCL system.xxx. & co. I have 3 months to navigate, explore and understand the code. This is my second resolution. Then I try the Isue … I have to find something easy at first, a FIXME or TODO basic to get into it.

Then there is the Windows code via the NDA Shared Source Initiative and there it is my regular favorite: read the Windows source code. For those who do not know C ++, this is the opportunity to get started. Buy my book “C ++ Aide-Mémoire” and ask for access to the Windows source code and admire the quality of the Windows Engineers code. I have a lot of respect for Windows code. Since I got my hands on the Windows NT4 and Windows 2000 leak (2 GB of source code) in the years 2000/2002, I have spent many hours studying this code. The kernel, RTL NTUser & co dlls, Shell, File Explorer. This is a Star Wars novel in 350 Volumes. It’s beautiful. It’s complex but at the same time subtle and organized. Damn, it’s good! That’s why I have so much admiration for Bill Gates. Windows is a flagship of technology. OK sometimes it’s good old C / C ++ but it works fast and well.

When I discovered Windows Internals (7th edition Part 16th Edition Part 16th Edition Part 2) in the 2000s, I saw the virgin because it helped me understand Windows sources then when I discovered Windows Protocols (https://docs.microsoft.com/en-us/openspecs/protocols/ ms-protocolslp / 9a3ae8a2-02e5-4d05-874a-b3551405d8f9), that was the grail. When I was at Services in 2017, I was surprised, people don’t know that. The culture of the NET means that people are very little cultivated on Windows while it is the flagship of the company. OK, now there is Azure but hey Azure is Windows Server and Service Fabric and all that is Windows. I ignore the Linux part … Each Microsoftie should be offered to deliver Windows Internals for its arrival in the company!

In short you will understand, my goal is to work for Corp. I’m working on it. Being blacklisted at Services France, I will find a way to get out of it via GitHub and my relationships with the Visual C ++ team in the US. My friend Simon Brand is a good C ++ advocate and yet lives in Edinburg, UK. France is very special … C ++ is limited. The companies for Services make, for the development with Microsoft Technologies, C # / NET.

Happy New Year to all the girlfriends.

Kisses to my mentor EricV. Kisses to EricMitt. Kisses to Alain.

Kisses to Agnes, my HEXV2 Project Director of OBS in 2006…. We got on well with GGray, PCP, Nicolas. I’m still in touch with the ex-OBS colleagues for whom we had to replace their Linux system (700,000) BAL POP / IMAP with Exchange Server via HMC… We meet regularly over a beer with Gael Roualland, the little genius from OBS who gave us a hard time and his friends at the time. Since I also switched to Debian Linux and Ubuntu (C ++ requires), they accept me but chamber me by saying that Microsoft is my best enemy so I love you either. They tell me to dump everything on builder than on Linux and that I would be more successful than with Microsoft … I disagree. 25 years of C ++ Microsoft, it does not give up, on the contrary, it is currency. And when you love, you don’t count your efforts.

Christophe | www.christophepichaud.com

C++ unsafe and unsecure ?

My colleagues in the Microsoft world and others tell me that C ++ is outdated, too difficult, too old, too hard to master and there are even some who tell me that it is unsafe and unsecure!

I laugh.

If C ++ had all of these flaws, Microsoft wouldn’t make 95% of these products with it. I’m going to come back to unsafe and unsecure because it’s very interesting. But before a reminder: EVERYTHING YOU HAVE ON YOUR PC AND MAC IS DONE IN C ++. Windows, Office (Word, Excel, PowerPoint, Outlook), IE, Chrome, VLC, Notepad ++, Calc, MSPaint, Photoshop, File Explorer, Process Explorer, etc…

To sell .NET Marketing has tried to discredit C ++ because it is too rich, too powerful and does not need advertising or marketing. In the 2000s, marketing tried to sell the idea that a language that manipulates memory finely is likely to crash and that the panacea was the Garbage Collector. This reasoning is an intellectual scam.

Just because a language like C or C ++ allows you to manipulate memory finely to the byte does not mean that it crashes or corrupt memory. Marketing, which is a contingent of people coming out of business schools, knows nothing about the technique and therefore these people are making crude short cuts. It must be said.

For those who are curious, the NET or CLR (Common Language Runtime) virtual machine is made in C ++ so here, the loop is complete. If C ++ was that bad, CLR would not be done in C ++. The garbage collector and the JIT either! The problem is that NET has to fight against an opponent that was there before it, namely Java and that the competition is raging. Java is much more established in companies than NET and that in spite of billions invested in marketing and publicity.

So I ask the question: was trying to discredit C ++ a good way to sell NET to the developer world? I do not believe. C ++ is ISO standardized and has millions of developers. The C ++ language does not need advertising, it is the language of industry, medical, software publishing, games, etc. C ++ has been there for 40 years and has undergone extensive renewal. It’s no longer C ++ at Papa, the famous C ++ 98 or C + 03. We moved to Modern C ++, the one that frees memory automatically via intelligent pointers or smart pointers, that of lambdas, that of move semantic. Marketing doesn’t talk about it, of course… Marketing isn’t mathematics, it’s not scientific and that’s why we should be wary of it.

In the field of software design, you should never believe in marketing and always rely on scientific reasoning. You have to test the technologies and make your own opinion and always be factual.

I have access to the Windows source code and everything is done in C / C ++. It’s modern C ++ and it’s clean. Windows will always be written in C ++.

The last news of the moment is to push Rust as a kernel language to solve memory problems. This is a false debate because the kernel includes a Memory Manager (mm) which manages virtual memory and only C ++ can write such a module. Some researchers have no knowledge of operating systems and are trying to make the buzz around Rust with a marketing approach … that’s it, they are setting the scene. Let them speak, Microsoft will never rewrite Windows in Rust. There are millions of lines of code. And contrary to what newspapers say for managers like 01 Informatique, Microsoft does not rewrite the OS from scratch. That would be known. Microsoft has been evolving Windows for 25 years. And it’s C ++. No offense to Marketing.

Large software is made in C ++. Another Nth example? Chrome and NodeJS. We cannot salute the JavaScript revolution without thinking of C ++. NodeJS is pure C ++ and Chrome too. Microsoft has made it its new browser with Chromium. Chrome is browser-based software that powers billions of computers and is fast, reliable, and powerful. Long live C ++!

C ++ RENAISSANCE

POWER AND PERFORMANCE

“THE WORLD IS BUILT ON C ++”, Herb Sutter.

Send me your comments on my email: christophep@cpixxi.com.

Microsoft’s UI development model

The future of graphic world (UI) at Microsoft is called WinUI. WinUI are the XAML controls of Windows 10. They’re made of C/C++.

Windows 10 makes extensive use of them and offers them (finally) full access to everyone: NET, C++, Win32.

Microsoft is committed to C++. Windows too. Microsoft makes its software in C/C++ because It’s fast and efficient. Do you understand my innuendo? On the Microsoft site, if you are looking to do software development, you are referred to .NET by default. I ask the question: but why?

Microsoft doesn’t. Why would I? Microsoft is no longer in dog-fooding as before. There is an internal discourse and an external discourse.

Internally, there is no debate, we do almost everything (90%) C/C++. Windows, Office, Edge, etc.

Externally, we only promote .NET, the web, JS/TS, Angular and python!

Where I laugh is that Microsoft evangelists who spend their time taking pictures of their hamburger meal on twitter know nothing about the native world and there is a problem for example, on WinUI. There is no one left to explain the real Microsoft, the one from the inside.

On WinUI, you have to promote XAML Islands, Controls in C++ and how to explain how to mix it with MFC and Win32 controls for example. Result: nothing. There’s no one who knows how to do it.

As an MVP, I’m going to focus on that. but it’s not normal for Microsoft not to fulfill its share of Learning.

Sometimes I have discussions with developers who think that Windows is made in C#???? WTF! The level of knowledge of the Microsoft company is leveled from the bottom. .NET architects believe that desktop graphics interfaces should be made in WPF. Oh, yes? Why doesn’t Microsoft do it then?

The future is C++ and .NET Core. It’s not ony .NET and C#. NET and its CLR is powered by C++.

Multiplatform development with C++

To develop multi-platform applications, there are not fifty possible choices, there is only one that is free and efficient: it’s C++.

Only the C/C++ can take advantage of the latest developments in Windows, Linux, Android and iOS SDKs because the system and its environment are made with it. The advantage of C++ is that it ‘builds on the metal’: there is no faster. It takes advantage of the software architecture of the operating and hardware systems of the latest x86, x64 and ARM processors. For forty years, C++code optimizers have guaranteed the best possible quality of code.

C, It’s the new assembler. C++, It allows the object oriented: abstractions, inheritance and polymorphism (virtual functions), overload of operators, templates. With its STL (Standard Template Library) bookstore and in conjunction with a bookstore such as Boost (boost.org), the C++ a-has a universal toolbox that handles strings, containers (collections), algorithms, I/O, threads, smart pointers, communications, etc.

Take the plunge. Install Visual C++ Windows, GCC Linux, XCode on Mac and share business code. Make rich graphical interfaces and take advantage of the best development language that’s C++.

You will tell me there are hybrid solutions like NET or Java? These solutions are a set of thousands of heavy, slow sheets that do not create world-class applications. In cars, there are Fiat 500s and Ferraris. At the same price (see cheaper), what do you take? There’s no photo…

Article for Programmez November 2019

In Issue n°234 or French magazine Programmez for November 2019, I have written an article about How to become a Microsoft Technical Expert.

Article for Programmez October 2019

In the N°233 Issue of Programmez magazine, I have written a technical article about Windows Subsystem for LInux v2 (WSL2).

Making a POST call with JSON data using CPPREST C++ SDK

The source code here is the same as the C# version in the previous post. The client makes a simple call like that: 

	std::string value2 = "azertyuiopqsdfghjklmwxcvbn";
	std::string buffer = Base64Helper::base64_encode((const unsigned char*)value2.c_str(), value2.length());
	std::wstring value3(buffer.begin(), buffer.end());
	SetData(key, value3, value3.length(), dbname);

 

Here is the wrapper code for SetData. It’s included in HttpLMDB dll: 

bool HTTPLMDB_API SetData(std::wstring key, std::wstring valueb64, DWORD dwLen, std::wstring name)
{
	std::wstring port = Constants::MasterNodePort;
	std::wstring ip = ServerHelper::GetIP();
	std::wstring url = ServerHelper::BuildURL(ip, port);

	std::wstring contentType = _T("Content-Type");
	std::wstring contentTypeV = _T("application/json");
	std::wstring keepAlive = _T("Keep-Alive");
	std::wstring keepAliveV = _T("false");
	std::wstring contentLength = _T("Content-Length");
	
	std::wostringstream bufLen;
	bufLen << contentType.length() + contentTypeV.length() + keepAlive.length() + keepAliveV.length() + contentLength.length() + 4;
	std::wstring len = bufLen.str().c_str();

	std::wostringstream buf;
	buf << url << '/' << Constants::Request << Constants::VerbSetDataB64
		<< _T("&name=") << name;
	url = buf.str().c_str();	
	//{"key":"key_toto0","value":"value_toto0"}
	std::wostringstream bufjson;
	bufjson << "{" << '"' << "key" << '"' << ":" << '"' << key << '"' << ","
		<< '"' << "value" << '"' << ":" << '"' << valueb64 << '"' << '}';
	std::wstring jsonv = bufjson.str().c_str();
	//wcout << _T("jsonv : ") << jsonv << endl;

	http_client client_lmdb(url);
	http_request request(methods::POST);
	request.headers().add(contentType, contentTypeV);
	request.headers().add(keepAlive, keepAliveV);
	request.headers().add(contentLength, len);
	request.set_body(jsonv);

	http_response response;
	response = client_lmdb.request(request).get();

	wcout << response.to_string() << endl;

	return true;
}

 

Here is the code. It’s not very difficult.

Handling a long url using POST verb

To be able to store data in my LMDB Service, I need to store data as base64 items. To do that, I need to transmit json data from the client to the server. It can’t be passed on the url. So I use post handling. Here is the C++ handler:

void TheServer::handle_post(http_request message)

{
       try
       {
             g_Logger.WriteLog(_T("handle_post"));
 
             PrintRequest(message);

             std::wstring request = ServerHelper::FindParameter(message, _T("request"));
            
              if (request == Constants::VerbSetDataB64)
             {
                 RequestVerbSetData64(message);
                    return;
             }
             else if (request == Constants::VerbGetDataB64)
             {
                    // Does not work yet
                    RequestVerbGetData64(message);
                    return;
             }
       }
       catch (...)
       {
             // an internal problem occured
             g_Logger.WriteLog(_T("handle_post exception..."));
       }
 
       message.reply(status_codes::OK);
};

 

The C++ routine here to analyze is RequestVerbSetData64. Here is the code:

void TheServer::RequestVerbSetData64(http_request message)
{
       USES_CONVERSION;
       CLMDBWrapper lmdb;
       g_Logger.WriteLog(Constants::VerbSetDataB64.c_str());
 
       std::wstring dbNameW = ServerHelper::FindParameter(message, _T("name"));

       std::string dbName(dbNameW.begin(), dbNameW.end());
       std::wstring json;
       web::json::value jsonV = message.extract_json().get();

       Data data = Data::FromJSON(jsonV.as_object());
       TCHAR sz[255];
       _stprintf_s(sz, _T("Data key:%s value:..."), data.key.c_str());
       g_Logger.WriteLog(sz);

       if (lmdb.Init((LPSTR)dbName.c_str()) == false)
       {
             g_Logger.WriteLog(_T("LMDB Init not done !"));

            message.reply(status_codes::OK);
             return;
       }

       LPSTR lpszKey = W2A(data.key.c_str());
       LPSTR lpszValue = W2A(data.value.c_str());
       DWORD dwLen = strlen(lpszValue);

       lmdb.SetData(lpszKey, lpszValue, dwLen);

       message.reply(status_codes::OK);

       lmdb.Uninit((LPSTR)dbName.c_str());
}

 

The source code is simple to write, simple to read. Because it is native code, it is fast and we just need to distribute the dll we use. here, it’s just the C runtime, the C++ runtime and the CPPREST dll. This is the advantage of the native stuff, you don’t need to distribute any framework that size is around 350 MB… It’s lightweight, it’s fast, it’s built on the metal.

Microsoft REST SDK Architecture

The architecture of the Microsoft CPPREST SDK is presented here for an article I write for french magazine Programmez.

It explains why the code is multi-platform. It’s based on Boost libraries. Boost is known to be a very good library, state of the art C++.

Article in Technical Magazine Programmez N° 219 – June 2018

May be in next June edition of french magazine Programmez, an article about creating a Windows Service. All the plumbing ! The second part will explain how to host a deamon inside and respond to external communication.

Create a simple cache in C# .NET

Here is a little sample of code I have written to simulate a cache, wich write the data every second on disk in the background in a dedicted thread.

Using this class Engine, you can write data to the internal dictionary and keep it safe because the database is written to disk… I do not have handled the reload of the data in the ctor… Here the client program who write any number of values you want:

If I run the console application using different values, here is the result:

D:\Dev\MyCache\ConsoleApp1\bin\Debug>ConsoleApp1.exe 10
Count: 10
Time elapsed set: 0 ms
Time elapsed get: 0 ms
Writing DB…
Writing DB OK

D:\Dev\MyCache\ConsoleApp1\bin\Debug>ConsoleApp1.exe 100
Count: 100
Time elapsed set: 0 ms
Time elapsed get: 0 ms
Writing DB…
Writing DB OK

D:\Dev\MyCache\ConsoleApp1\bin\Debug>ConsoleApp1.exe 1000
Count: 1000
Time elapsed set: 1 ms
Time elapsed get: 1 ms
Writing DB…
Writing DB OK

D:\Dev\MyCache\ConsoleApp1\bin\Debug>ConsoleApp1.exe 10000
Count: 10000
Time elapsed set: 7 ms
Time elapsed get: 13 ms
Writing DB…
Writing DB OK

D:\Dev\MyCache\ConsoleApp1\bin\Debug>ConsoleApp1.exe 100000
Count: 100000
Time elapsed set: 98 ms
Time elapsed get: 140 ms
Writing DB…
Writing DB OK

D:\Dev\MyCache\ConsoleApp1\bin\Debug>ConsoleApp1.exe 1000000
Count: 1000000
Writing DB…
Writing DB OK
Time elapsed set: 3656 ms
Time elapsed get: 4023 ms
Writing DB…
Writing DB OK

Source code here: MyCache.zip

Article in Technical Magazine Programmez N° 218 – May 2018

In May 2018, you will discover a technical article How to build under 64 bits environment. It contains tips&tricks for handling the migration because the source code will not compile as easy you can think…

 

LMDB for Windows

When I discovered the fantastic history of LMDB, It fascinated me. For a R&D projet, we need to present something that looks sexy and with a strong architecture. I proposed to study LMDB and bring to it the distributed engine and the clustering stuff with nodes. There are plenty ways of acheiveing this.

First, OpenLDAP-LMDB need to be ported on the Windows platform. It’s a C based code so there are no some many changes to fix for building on Windows. There was a path concat that made some problems but it’s defined as constants so I fixed it rapidly. I put it in Github after the operation was done.: https://github.com/ChristophePichaud/LMDBWindows

I was able to build a static lib for LMDB. But in Windows, we love shared modules called DLL so I have to put some little things on the source code to enable loading shared modules DLL (Dynamic Link Library).

#ifdef LMDBWINDOWSDLL_EXPORTS
#define LMDBWINDOWSDLL_API __declspec(dllexport)
#else
#define LMDBWINDOWSDLL_API __declspec(dllimport)
#endif

With theses expanded macros, it can export functions. Every headers and bodys need to be decorated. Here is the explaination. When you build the library, you define de constant LMDBWINDOWSDLL_EXPORTS in the project settings then every macros instruct the compiler to export the functions. When you build an application who needs the dll, the macro is expanded as an import operation and at the link phase, you need to link with the little stub to attach the library.

If you are new to Windows DLLs making, check this portion of doc on MSDN: https://msdn.microsoft.com/en-us/library/a90k134d.aspx

Enter in the world of NoSQL engines

Sometimes ago, I had to discover a source code, as is. It was a database engine. A big software, powered by C/C++ using linux tools. I always install cygwin on my machines so there was no problem. Tools where Bison, lex and sed. Some bash scripts to put files on common folders & some other stuff. The storage engine was powered with LMDB. It’s the fastest engine on the market, they said in a README.MD. There was also a data structure that was associated with a registered patent.

I have read a lot of wikipedia on NoSQL engines and I have inspected a lot of source code like LMDB and Redis. It’s all about C, it’s brutal and very efficient. It fascinates me. And so what for ?

I currently work on a R&D project to put a NoSQL engine on a Windows service and install it on a Docker image and run it in Azure Container Instances (ACI). As a Micrcosoft partner, my company has to work with Azure and win competencies. Because it’s a R&D project, we have ambitions : make a Redis like software. With distributed features. We want superior performance versus DocumentDB. It will be powered by LMDB. More to come in coming weeks. Stay tuned.

Unit tests in C++

For magazine Programmez, I have made a review of Unit Testing Frameworks. I have described CPPUnit and Google Tests with it’s adapter for Visual Studio. There are two ways to tests the UT : console or Visual Studio Test Exeplorer Window.

I must admit I prefer the console version for running my tests.

Building Boost x86 and x64 – HOWTO

Just a reminder (for me). The command line to rebuild boost library with VS2017 is:

> boostrap.bat

> bjam toolset=msvc-14.1 variant=debug,release threading=multi link=shared address-model=64

VSDemo App Version 1.1 January 2018

My light weight IDE is updated…  The download link is always: www.windowscpp.com/Appz/VSDemo.zip

The source code is on GitHub : https://github.com/ChristophePichaud/VSDemo

You can build the source code and run the program. The code is compiled using Roslyn compiler which is shipped into the package.

An IDE made with C++ and MFC – Part II

For the January 2018 edition of the french magazine Programmez, I have written an article about building an IDE with open-source project Scintilla and Roslyn, the Microsoft C# compiler. My goal is that my daughter Lisa, 12 ans, can begin learning software development on it. The code is available on GitHub: https://github.com/ChristophePichaud/VSDemo

 

VSDemo is now upgraded with many features…

“Open Folder” is the best feature of the IDE:

But if you want more comfort, check Enable Full-Screen :

All of the magic is done by the MFC framework. It’s beautiful and cool. :)