Check if compiler is Turbo C++

972 Views Asked by At

I am currently dealing with legacy code designed for Turbo C++. To work around Turbo C++'s lack of a bool data type, the program contains the following line of code.

// Necessary when compiling with Turbo C++
enum bool {false, true};

Most C++ compilers fail to run the program with error: expected identifier before 'bool'. While I would love to switch to a more recent compiler, I am unfortunately required to maintain this workaround for backwards compatibility.

How can I indicate that this specific line of code should only compile in Turbo C++?

1

There are 1 best solutions below

0
Stevoisiak On BEST ANSWER

As suggested by Thomas Matthews and selbie in the comments:

#ifdef __TURBOC__
    // Only runs if compiler is Turbo C++
    enum bool {false, true};
#endif

Source: http://beefchunk.com/documentation/lang/c/pre-defined-c/precomp.html