Help save net neutrality! Learn more.
Close

#1964 LPTSTR and TCHAR have different pointer size

OTHER
closed
nobody
None
Bug
self-service
Behaves_as_Documented
False
2013-04-30
2013-04-29
No

When cross-building metapad I get this warning:
metapad.c:6181: warning: cast to pointer from integer of different size
metapad.c:6181: warning: cast from pointer to integer of different size

They come from this line (there are a few duplicates of the same kind of warning and same kind of casting):
TCHAR chOption = (TCHAR)CharLower((LPTSTR)szCmdLine[1]);

However, TCHAR is a char string with proper char size depending on being or not unicode, and LPTSTR is a pointer to an array of char strings, with char size depending on unicode being or not defined. This means an element of a LPTSTR MUST have the same pointer size of a TCHAR, since this would actually be an array of TCHARs.

To reproduce, clone this git https://github.com/Oppen/metapad/commits/master and run:
$ make --file=Makefile.custom.linux

You should see the warnings.
MingW32 GCC version is 4.2.1, and MingW32 version is 3.15.2.

Discussion

  • Mario Rugiero

    Mario Rugiero - 2013-04-29

    Sorry for bothering, it's obvious now that the comparison is not between pointers, and that's why the warnings come up.

     
  • Earnie Boyd

    Earnie Boyd - 2013-04-30
    • status: unread --> closed
    • Resolution: none --> self-service
     

Log in to post a comment.