Showing posts with label c++. Show all posts
Showing posts with label c++. Show all posts

Friday, June 02, 2017

Visiting an old friend

In the (not) good old days of single-user single-process MS-DOS TSR programs were a kind of magic wish: have more than one program running at same time.

Companies created TSR utilities. I can remember of Borland Sidekick and Norton Guides, among others.

Of course I couldn't leave behind. Around 1990 I created my own TSR program: TASCII. An ASCII table very useful for... me only.

I based my implementation on the excellent Al Stevens' Extending Turbo C Professional book.

Recently I attempted, just for the fun, to bring back TASCII to life again.

I began with the DOSBOX MS-DOS emulator. For the compiler I used Turbo C 2.01 which Borland (now Embarcadero) made available for free, years ago. Unfortunately I hadn't the full source code for the Extending.. book. So I had to borrow it from openlibrary.org and type the missing parts.

Well, here it is (for the real nostalgia DOSBOX has a CGA mode):











Who needs a resident ASCII table these days? But it is nice to see an old friend again.

(If you are also insane I can provide you with the binary).

Friday, August 10, 2012

GCC macros for portable development

While GCC define a large number of macros only some of them are useful for portable development. The use of pre-processor macros is a well-known technique for selecting which portions of your code can only be compiled on a specific platform.

The most interesting macros are:

  • __GNUC__: always defined for GCC
  • __GNUG__: always defined for G++
  • WIN32: defined on Windows only

This code:

#ifdef __GNUC__
  #ifdef WIN32
    std::cout << "GCC on Windows\n";
  #else
    std::cout << "GCC not on Windows\n";
  #endif
#endif

Outputs:

GCC on Windows

when built with MinGW on Windows and

Outputs:

GCC not on Windows

when built with GCC in other platforms.

Alternatively with MinGW you can also use __MINGW32_VERSION which is defined if _mingw.h is directly or indirectly (e.g. by including any standard header file) included.