Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check if compiler is Turbo C++

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++?

like image 431
Stevoisiak Avatar asked Oct 15 '25 02:10

Stevoisiak


1 Answers

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

like image 113
Stevoisiak Avatar answered Oct 17 '25 17:10

Stevoisiak



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!