Define for Tcl_Size not present when compiling against Tcl 8.6.17
"Tcl_Size" itself doesn't need to be provided as long as you update the extension to the latest tclconfig release. TEA (latest tcl.m4/rules.vc files) takes care of providing an appropriate preprocessor #define for Tcl_Size.
I tried this to comply to this ticket https://github.com/tcltk-depot/tksvg/issues/27.
I replaced TkSizeT by Tcl_Size.
The compilation using makefile.vc and MS-VC6 32 bit on MS-Win 11 64 bit states:
C:\test\git\tksvg\win\..\generic\tkImgSVG.c(93) : error C2146: syntax error : missing ')' before identifier 'length' C:\test\git\tksvg\win\..\generic\tkImgSVG.c(93) : error C2081: 'Tcl_Size' : name in formal parameter list illegal
I looked, if Tcl_Size is given by a define as stated by the wiki page. The compiler invocation has no "-D Tcl_Size".
cl -nologo -c /D_ATL_XP_TARGETING /DHAVE_CPUID=1 -W3 -wd4090 -wd4146 -FpC:\test\git\tksvg\win\Release\tksvg_ThreadedDynamic\ -Op -QI0f -O2 -YX -MD -I"C:\test\tcl8.6.17\tcl8.6.17\generic" -I"C:\test\tcl8.6.17\tcl8.6.17\win" -I"C:\test\tcl8.6.17\tk8.6.17\generic" -I"C:\test\tcl8.6.17\tk8.6.17\win" -I"C:\test\tcl8.6.17\tk8.6.17\xlib" -I"C:\test\git\tksvg\win\..\generic" -I"C:\test\git\tksvg\win\..\win" -I"C:\test\git\tksvg\win\..\compat" -Dinline=__inline /DSTDC_HEADERS /DUSE_NMAKE=1 /DMP_NO_STDINT=1 /DTCL_THREADS=1 /DUSE_THREAD_ALLOC=1 /DNDEBUG /DTCL_CFG_OPTIMIZED /DNO_STRTOI64=1 /DUSE_TCL_STUBS /DUSE_TCLOO_STUBS /DUSE_TK_STUBS /DPACKAGE_NAME="\"tksvg\"" /DPACKAGE_TCLNAME="\"tksvg\"" /DPACKAGE_VERSION="\"0.15\"" /DMODULE_SCOPE=extern /DBUILD_tksvg -FoC:\test\git\tksvg\win\Release\tksvg_ThreadedDynamic\ @C:\Users\oehhar\AppData\Local\Temp\nmc09512.
So, how should this work ?
Paul wrote, that the "Tcl_Size Magic Code" has to be integrated. This code is:
#ifndef TCL_SIZE_MAX
#include <limits.h>
#define TCL_SIZE_MAX INT_MAX
#ifndef Tcl_Size
typedef int Tcl_Size;
#endif
#define TCL_SIZE_MODIFIER ""
#define Tcl_GetSizeIntFromObj Tcl_GetIntFromObj
#endif
Why is this not stated on the wiki page?
Thanks for all, Harald
It was stated on the Wiki page at one point. It was explicitly removed in this edit.
Personally, I still believe defining Tcl_Size in configure/rules makes no sense as you still have to define others (TCL_SIZE_MODIFIER, TCL_SIZE_MAX etc.) in the extension. But it is what it is given others feel otherwise ...
You may possibly need to update your tclconfig.
Ashok, thanks for hte answer.
I have updated the tclconfig as stated by the wiki page. To my understanding, tclconfig is irrelevant for win\Makefile.vc
It just does not work, sorry.
I don't care about tclconfig. It is over-complicated for my head, sorry. TIP 723 also requires TCL config magic for Linux, which will probably block the TIP for a long time....
Take care, Harald
Harald, I was primarily answering your question "Why is this not stated on the wiki page?" in that it was stated at one time but removed in the commit I linked by Jan, presumably because he thought it was not needed. I only pointed to tclconfig because of the advice added (in that page) suggested updating tclconfig would fix such issues. FWIW, I use boilerplate similar Paul's in all my extensions.
Thanks for the clarification.
So, to resume:
- Tcl_Size is eventually defined by "-DTclSize=int" when using the tclconfig build method
- Tcl_Size is undefined with the Makefile.vc method
- The code by Paul is the right way to go on Makefile.vc
So, the wiki page should be updated to reflect this. It is a pity, that the two build methods are incompatible, but that is life.
Thanks for all, Harald
The makefile.vc build set's Tcl_Size as well. See this line.
So, it should be enough for extensions to update "rules.vc" to the latest version, then it should work for any platform.
I see why it doesn't work with tksvg: tksvg doesn't distribute its own "rules.vc", so the one distributed with Tcl is used. The "rules.vc" distributed with Tcl 8.6 doesn't set Tcl_Size.
So, an alternative solution for tksvg would be to supply the latest "rules.vc" in the /win directory. Then it doesn't have to take care about Tcl_Size any more. It's just a choice, the current solution is OK too :-)
Ja, thanks for the answer !
My TCL version was 8.6.15. This line has a condition to only work until TCL 8.6.
!if $(TCL_MAJOR_VERSION) == 8 && $(TCL_MINOR_VERSION) < 7 cflags = $(cflags) -DTcl_Size=int !endif
So, I don't think, this line would help.
Thanks for all, Harald
Sorry, stupid comment. I may retest.
I will recheck.
I don't know how to get the rules.vc. What I understood is, that it is taken from TCL and my TCL is 8.6.15. Should it be in there?
Thanks for all, Harald
Thanks, I just want to make it right. I followed the wiki and it failed. If this failure is intendet that this failure should be noted on the migration wiki page (intended not to work if not own rules.vc distributed).
Is it really desired to distribute the own "rules.vc"? I thought, we have overcome this to get automatically enhancements from TCL into extensions.
Thanks for all, Harald
The discussion was probably done before. Why is Tcl_Size not defined by tcl.h also in 8.6?
I prefer a typedef instead of a #define. The compiler may do better checks and it is more transparent what is happening.
Thanks for all, Harald
Is it really desired to distribute the own "rules.vc"?
Generally, no. There are two reasons for one's own rules.vc -
- you want extensions to be able to build against older (pre 8.6.10 I think) version of Tcl
- you are using rules.vc features available in newer versions of Tcl, (say 8.6.17) but building against an older Tcl whose rules.vc does not have that feature.
I am not sure when the Tcl_Size define was added to rules.vc. Also, whether the version in rules.vc was updated with the change.
/Ashok
To conclude:
- Tcl_Size is always a define, if TCL_MAX_SIZE is not defined
- Tcl_Size define may be present or not
So, the boilerplate given by Paul solves all use-cases.
I will update the wiki page to include this.
Thanks for all, Harald
Ok, wiki page updated by commit [f411653044].
The additional proposed
#define Tcl_GetSizeIntFromObj Tcl_GetIntFromObj
is not handled.
THanks for all, Harald