1

If I can do this in Delphi,

{$IFDEF VER350}
    /* Declare, define, do stuff ... */
{$ENDIF}

why can't I do this in C++Buider,

#ifdef VER350
    // Declare, define, do stuff ...
#endif

How do I get the compiler version in C++Builder?

Mark Di Val
  • 81
  • 1
  • 7

1 Answers1

3

Because the compiler doesn't define the same macro or do that kind of thing in the same way as Delphi.

According to this webpage, the macro you are looking for is called __BCPLUSPLUS__ and you have to check if it is equal to the version code you are looking for. See this page for the Delphi - C++ Builder equivalents.

However, the versioning is not quite as straight forward as in the case of Delphi and the table at the bottom of the page doesn't seem to have been updated to include the version of C++ Builder that corresponds to Delphi VER350. Still, it stands to reason that since the VER340 equivalent is listed as 0x0750 and the one before that was 0x0740, then the latest is most likely 0x0760. It is an easy check on your end in any case.

It would look something like

#if __BCPLUSPLUS__ == 0x0760
...
#endif
dandan78
  • 13,328
  • 13
  • 64
  • 78
  • 2
    "*the macro you are looking for is called `__BCPLUSPLUS__`*" - there is also `__TURBOC__`, `__TCPLUSPLUS__`, `__BORLANDC__`, `__CODEGEARC__`, and `__CODEGEARC_VERSION__`, all of which contain the compiler version number. Historically, `__BORLANDC__` is the one most commonly used, though with the push to move everything to Clang, consider `__CODEGEARC(_VERSION)__` instead. – Remy Lebeau Mar 30 '22 at 19:04