| Ticket UUID: | 2026405 | |||
| Title: | winfo id bug in cygwin build | |||
| Type: | Bug | Version: | None | |
| Submitter: | nuchida | Created on: | 2008-07-24 05:04:36 | |
| Subsystem: | 85. Win Build | Assigned To: | mdejong | |
| Priority: | 5 Medium | Severity: | ||
| Status: | Closed | Last Modified: | 2008-07-26 18:52:55 | |
| Resolution: | Fixed | Closed By: | patthoyts | |
| Closed on: | 2008-07-26 11:52:55 | |||
| Description: |
Please excuse my poor English. TkpPrintWindowId() in tk/win/tkWinWindow.c uses sprintf() with format specifier "0x%p" msvc generates ordinary hex string like "8048354" for "%p", so "0x%p" generates string like "0x8048354". On the other hand, gcc (which is used by cygwin) adds "0x" prefix for "%p", so "0x%p" results in "0x0x8048354". This is not what you want. It would be nice if TkpPrintWindowId() checks _MSC_VER or something, and considers compiler-specific situations. | |||
| User Comments: |
patthoyts added on 2008-07-26 18:52:55:
Logged In: YES user_id=202636 Originator: NO It seems the output of %p is platform or at least libc specific. So added a check for 0x0x... and if we see this, regenerate without the 0x prefix. Backported to 8.5 branch. nuchida added on 2008-07-26 11:14:58: Logged In: YES user_id=2156845 Originator: YES > And 64 bit windows exists Yes, I know that. "%p" is portable and safe under 64 bit OS, but the result might not look the same. When someone tries to parse the result string, it causes some trouble (Actually, Python's Tkinter does. It tries to parse "winfo id" command's output as integer). I think, in Unix-like OS, the implementation of printf-family actually depends on the system's libc (and not compiler's version). My linux-box uses libc6. If I install gcc3 or so, it will still produce the same result. In Windows, each compiler uses it's own libc (except for Mingw, which uses msvcrt). It might be a headache if Tk is willing to support all of them. But if Tk officially supports only msvc in Windows and doesn't take care of cygwin, this wouldn't be a "bug", and it can't be helped. patthoyts added on 2008-07-25 21:44:39: Logged In: YES user_id=202636 Originator: NO Using the example C file below: MSVC 6 msys-gcc solaris gcc solaris 64bit 00401000 004012F0 10670 10000083c 00401000 004012F0 0010670 0000083c My msys-gcc is 3.4.5 and on solaris its 3.4.3. Note that we need %p for 64 bit compiles. And 64 bit windows exists. Could be a gcc 4 issue? nuchida added on 2008-07-24 17:17:40: Logged In: YES
user_id=2156845
Originator: YES
Thanks for your quick response.
Well, gcc in my linux-box gives the same result.
Is it a gcc bug or something?
I think the C standard gives no specification for "%p" formatting, and how the result looks like is "implementation defined". I think this is not a bug of gcc.
$ gcc -v
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --program-suffix=-4.1 --enable-__cxa_atexit --enable-clocale=gnu --enable-libstdcxx-debug --enable-mpfr --with-tune=i686 --enable-checking=release i486-linux-gnu
Thread model: posix
gcc version 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)
$ cat t.c
#include <stdio.h>
int main()
{
printf("%p\n", main);
printf("%08x\n", main);
return 0;
}
$ ./a.out
0x8048354
08048354
nuchida added on 2008-07-24 17:14:06: Logged In: YES
user_id=2156845
Originator: YES
Thanks for your quick response.
Well, gcc in my linux-box gives the same result.
Is it a gcc bug or something?
I think the C standard gives no specification for "%p" formatting, and how the result looks like is "implementation defined". I think this is not a bug of gcc.
$ gcc -v
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --program-suffix=-4.1 --enable-__cxa_atexit --enable-clocale=gnu --enable-libstdcxx-debug --enable-mpfr --with-tune=i686 --enable-checking=release i486-linux-gnu
Thread model: posix
gcc version 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)
$ cat t.c
#include <stdio.h>
int main()
{
printf("%p\n", main);
printf("%08x\n", main);
return 0;
}
$ ./a.out
0x8048354
08048354
nijtmans added on 2008-07-24 15:34:49: Logged In: YES
user_id=61031
Originator: NO
I don't think that TkpPrintWindowId should assume anything
about the %p specifier. Actually, this is a cygwin bug,
because other UNIX'es (Linux, HP-UX) don't append "0x".
see: <http://man.he.net/man3/printf>
What if some day cygwin decides to fix this? The only
thing Tk could do is check if the string already starts
with "0x" and only prepend it when it is not prepended
yet, but I consider this a workaround for a cygwin bug.
Regards,
Jan Nijtmans
| |||
Home
Timeline
Branches
Tags
Forum
Tickets
Download
Wiki