Skip to content
This repository has been archived by the owner on Sep 22, 2022. It is now read-only.
/ AStarDemo Public archive

A basic A* implementation showing how to use C++20 modules alongside UWP and C++/WinRT.

Notifications You must be signed in to change notification settings

pjmlp/AStarDemo

Repository files navigation

Update

Since the respective C++/WinRT ticket for C++20 support has been closed, there is no use waiting for C++20 modules support, thus this effort is now archived.

Introduction

This is a port from an old application that was original written in a mix of C++14, Java and C++/CX.

Originaly the goal was to use a simple implementation of the A* search algorithm as basis for experimenting with writing a portable C++ based application application between Android and Windows (UWP) mobile platforms, as learning process for what it would entail to make it without using relying on third party libraries.

Now with the desmise of C++/CX and my focus on Windows development, I have decided to port the application from C++/CX into C++/WinRT.

With the goal being to learn about how to write proper C++/WinRT, the application remains as bare bones as in the previous learning experience, and got thiner as I removed the Android related code.

Then in 2021, after Visual C++ support for C++20 modules in UWP finally became stable enough, I managed to modularize the code, and also did some modern C++ related improvements.

There are thousands of fancy demo samples with tile engines and A*, this is not one of them, the only goal was to play with C++ language features.

C++ 20 Modules, Visual C++ and C++/WinRT

Although I managed to make it work, there is still plenty of work to do from Microsoft side.

  • Using header units triggers endless amount of macro redefinition warnings
  • C++/WinRT and XAML compiler don't understand modules, hence the strange import statements done on header files
  • Also why several places header files are included via global module fragments
  • Intelisense gives up most of the time and ctrl+space does nothing, or shows plenty of reds while it compiles just fine
  • Static analysis doesn't understand modules and fails to process any code
  • You might need to kill Visual Studio when trying to navigate across modules as it occasionally hangs
  • Mixing modules with pre-compiled headers on the same project doesn't work, so either split into two projects or disable pre-compiled headers

Still all in all, it is quite remarkable that it is working, and it can only get better.

Code Structure

The code is written in C++/WinRT, targeting Visual 2019 or later, composed of the following projects:

AStarDemo - The Windows UWP applications using C++/WinRT;

AStarDemoLib - The A* search algorithm implemented in portable modern C++ code, using modules.

AStarDemoLibTests - The unit tests for the A* library written with help of Google Tests testing framework.

Building

It is only required to open the project solution located at AStarDemo/AStarDemo.sln and do a full build.

Requirements

  • Visual Studio 2019 16.11.15 or later;
  • Windows SDK, including UWP workload

References

The wonderful A* tutorials from Amit Patel.

Tilesets

The tiles were taken from http://opengameart.org/content/simple-tileset

License

This example application is under GPL2 (except for the code generated by the Visual C++ project wizard).

About

A basic A* implementation showing how to use C++20 modules alongside UWP and C++/WinRT.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published