Tcl_GetErrorLine() forward compatibility

In a header file of your C/C++ application or extension that includes the Tcl library, add these lines

  #include <tcl.h>
  ...
  #if !defined(Tcl_GetErrorLine)
  #define Tcl_GetErrorLine(interp) (interp->errorLine)
  #endif

Why? This helps you deprecate direct access to interp->errorLine so you can upgrade your code written for pre-8.6 Tcl so it can be used with Tcl 8.6, yet still work with earlier Tcl releases.


JE It was earlier suggested to use:

  #if (TCL_MAJOR_VERSION < 8) || (TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION < 6)

You can do it that way too, but testing for the feature is preferable to testing for the version number in which the feature was introduced.


DGP I think the difference may be advice just for extensions (making USE_TCL_STUBS use of tcl.h) vs. advice good for both extensions and embedding applications (which are less likely to be using stubs).


LV It seems, to me, that tidbits like these would be really useful to collect somewhere to ensure that developers or maintainers don't overlook them. I'm not certain, however, of the best way to do this.

Changes to consider when moving to Tcl 8.6