Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2004-02-19
04:22 • Ticket [892037ffff] g++ compilation warnings status still Closed with 4 othe... artifact: ccafcaa528 user: npe
2004-02-07
12:10 • Closed ticket [892037ffff]. artifact: eb73c4c943 user: dgp
2004-02-06
19:51 • New ticket [892037ffff]. artifact: b516b68951 user: npe

g++ compilation warnings

Closed / Wont Fix892037ffffffffffffffffffffffffffffffffffCreated 23 years agoUpdated 23 years ago
Descriptionplain2004-02-06 19:51:53
OS Platform: Linux 2.4.9-34smp i686
Compiler: g++ 3.2.3

This is almost the same problem as mentioned in bug 
217999. It happens when calling Tcl_SetResults in C++ 
codes as:

Tcl_SetResult(interp, "any string", TCL_VOLATILE);

It will generate warning messages while compiled by 
using g++. Seems the parameter "string" will not be 
changed in this function, we might need to fix the type 
to be "CONST char *" instead of "char *".

Lei
([email protected])
dgpplain2004-02-07 12:10:52
Logged In: YES 
user_id=80530


Sorry, but the Tcl interface
was CONST-ified as much as
possible for Tcl 8.4. 

In particular, the second argument
of Tcl_SetResult() can't change from
type (char *) to type (CONST char *)
because when the third argument is
an actual Tcl_FreeProc, the second
argument really does have to be
a writable string to match the
Tcl_FreeProc signature.

When the third argument is TCL_VOLATILE,
you are correct that it really is safe
to pass a (CONST char *) in.  Knowing
that, you can feel free to add a
const cast in those function calls to
silence the compiler warnings.

Better yet might be to just call

  Tcl_SetObjResult(interp,
      Tcl_NewStringObj("any string", -1));

and move into the brave world of
programming to the Tcl 8 interface.  :-)
npeplain2004-02-19 04:22:44
Logged In: YES 
user_id=955134

Thanks a lot for response.
Log in (anonymous is fine) to add a comment.