Pascal Strings (using C++11 user-defined string literals)

This commit is contained in:
Wolfgang Thaller 2012-04-06 23:10:33 +02:00
parent 2ddb1c1849
commit dd1fe214cd
2 changed files with 9 additions and 1 deletions

View File

@ -16,4 +16,11 @@ public:
}
};
inline const unsigned char* operator"" _pstr(const char*p, size_t n)
{
unsigned char *pp = reinterpret_cast<unsigned char*>(const_cast<char*>(p));
pp[0] = n-1;
return pp;
}
#define PSTR(s) ("*" s ## _pstr)

View File

@ -11,6 +11,7 @@
#include <Events.h>
#include <Fonts.h>
#include "MacUtils.h"
#include "Console.h"
QDGlobals qd;
@ -56,7 +57,7 @@ int main(int argc, char** argv)
Rect r;
SetRect(&r, qd.screenBits.bounds.left + 5, qd.screenBits.bounds.top + 45, qd.screenBits.bounds.right - 5, qd.screenBits.bounds.bottom -5);
win = NewWindow(NULL, &r, (unsigned char*)"", true, 0, (WindowPtr)-1, false, 0);
win = NewWindow(NULL, &r, PSTR("Retro68 Console"), true, 0, (WindowPtr)-1, false, 0);
SetPort(win);
EraseRect(&win->portRect);