Picture this: you find yourself immersed in a new job, knee-deep in a C++ codebase, yet your heart yearns for the simplicity and elegance of Python syntax. What do you do? You don't just conform – you innovate, and boldly submit this to code review:
#include "pythonstart.h"
def greet(name):
print("hello, " + name + "!")
return
def greet2(name):
print("how are you, " + name + "?")
return
def bye():
print("ok bye!")
return
#include "pythonmid.h"
username = "Mat"
print("Hello from \"Python\"!")
greet(username)
greet2(username)
print("getting ready to say bye...")
bye()
#include "pythonend.h"
While reading through some code I wrote for a raytracing assignment, I noticed a peculiar function that had never caused any issues, but really looked like it should. After asking a bunch of people, I present this blog post to you!
As part of my game development major at DAE, I have to work on several projects which were not made with support for my platform of choice (Linux). Thankfully, most of these have been simple frameworks wrapping around SDL and OpenGL, so my job was limited to rewriting the build system from Visual Studio's .sln project file to a cross-platform CMake project (and fixing some bugs along the way). Not too bad. I'd miss the beginning of the first class, but was up and going shortly after. Among these were the first two semesters of Programming. Here's a list of school engines I have ported so far:
The versatility of having a cross-platform project allowed me to add tons of niceties for some of these. The one I'm most happy with is the “GameDevEngine2” framework from Programming 2, to which I added web support and ended up using it for my and 2FoamBoards's entry in the 2023 GMTK game jam.
Programming 3
I'd been having it easy. A couple nonstandard Microsoft Visual C++ (MSVC) bits of syntax here, a couple win32 API calls (functions that are specific to Windows) there... I wasn't expecting what arrived in my downloads folder today. I applied my usual CMake boilerplate, with SDL support, hit run to see the perhaps 50-100 errors... and instead was greeted with a simple but effective singular error.
apm@apg ~/S/Prog3 (main)> clang++ source/GameWinMain.cpp
In file included from source/GameWinMain.cpp:9:
source/GameWinMain.h:12:10: fatal error: 'windows.h' file not found
#include <windows.h>
^~~~~~~~~~~
1 error generated.
Oh, no
There's no SDL. There's no OpenGL. No GLFW, Qt, or GTK. It's all bare Windows API calls. I think I was in some form of state of disbelief, as I spent the next 30 minutes slowly creating #defines and typedefs to patch in all the types. Maybe, just maybe, I could patch around the types and it would magically open a window and I could get started with my classwork. No such thing happened.