Example application that demonstrates the use of the following:
- Operator overloading
- Free Operators
- Class Operators
- Friendship
- Iterator
// | |
// see also... | |
// | |
// CreateProcess (MSDN) | |
// http://msdn.microsoft.com/ja-jp/library/cc429066.aspx | |
// | |
#include <SDKDDKVer.h> | |
#include <windows.h> | |
int APIENTRY WinMain(HINSTANCE hInstance, |
#include <Windows.h> | |
#include <tchar.h> | |
#define CURRENT_WND_CLASS _T("GameWndClass_Didiet") | |
#define DEF_CX 800 | |
#define DEF_CY 600 | |
LRESULT CALLBACK WndProc( HWND, UINT, WPARAM, LPARAM ); | |
INT WINAPI _tWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow ) |
// Just before switching jobs: | |
// Add one of these. | |
// Preferably into the same commit where you do a large merge. | |
// | |
// This started as a tweet with a joke of "C++ pro-tip: #define private public", | |
// and then it quickly escalated into more and more evil suggestions. | |
// I've tried to capture interesting suggestions here. | |
// | |
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_, | |
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant, |
// Freestanding with MinGW: | |
// http://nullprogram.com/blog/2016/01/31/ | |
// http://nullprogram.com/blog/2016/02/28/ | |
// https://support.microsoft.com/da-dk/kb/99456 | |
#include <windows.h> | |
int WINAPI mainCRTStartup(void) | |
{ | |
char msg[] = "Hello, world!\n"; |
// Sample code showing how to create a modern OpenGL window and rendering context on Win32. | |
#include <windows.h> | |
#include <gl/gl.h> | |
#include <stdbool.h> | |
typedef HGLRC WINAPI wglCreateContextAttribsARB_type(HDC hdc, HGLRC hShareContext, | |
const int *attribList); | |
wglCreateContextAttribsARB_type *wglCreateContextAttribsARB; |
What is strict aliasing? First we will describe what is aliasing and then we can learn what being strict about it means.
In C and C++ aliasing has to do with what expression types we are allowed to access stored values through. In both C and C++ the standard specifies which expression types are allowed to alias which types. The compiler and optimizer are allowed to assume we follow the aliasing rules strictly, hence the term strict aliasing rule. If we attempt to access a value using a type not allowed it is classified as undefined behavior(UB). Once we have undefined behavior all bets are off, the results of our program are no longer reliable.
Unfortunately with strict aliasing violations, we will often obtain the results we expect, leaving the possibility the a future version of a compiler with a new optimization will break code we th
#include <stdio.h> | |
#include <stdlib.h> | |
#include <uchar.h> | |
#include <locale.h> | |
#define __STD_UTF_16__ | |
//Pointer arrays must always include the array size, because pointers do not know about the size of the supposed array size. | |
void utf8_to_utf16(unsigned char* const utf8_str, int utf8_str_size, char16_t* utf16_str_output, int utf16_str_output_size) { | |
//First, grab the first byte of the UTF-8 string |
// Set project as empty windows project. | |
// A game loop using PeekMessage function. | |
// Uses double buffering. | |
#include <Windows.h> | |
#include <time.h> | |
#include <math.h> | |
#pragma comment(lib, "winmm.lib") |
@echo off | |
echo. | |
openfiles > NUL 2>&1 | |
if %errorlevel% NEQ 0 ( | |
echo You are not running as Administrator... | |
echo This batch cannot do it's job without elevation! | |
echo. | |
echo Right-click and select ^'Run as Administrator^' and try again... | |
echo. |