mirror of
https://git.savannah.gnu.org/git/gperf.git
synced 2025-12-02 13:09:22 +00:00
Avoid warning in output code on 64-bit native Windows platforms.
This commit is contained in:
@@ -1,3 +1,12 @@
|
||||
2016-11-26 Bruno Haible <bruno@clisp.org>
|
||||
|
||||
Avoid 'warning: cast from pointer to integer of different size'
|
||||
in output code on 64-bit native Windows platforms.
|
||||
* src/output.cc (output_keyword_entry): Cast pointer to 'size_t',
|
||||
not to 'long', before casting it further to 'int'.
|
||||
* tests/*.exp: Update.
|
||||
Reported at <https://savannah.gnu.org/bugs/?45330>.
|
||||
|
||||
2016-11-26 Bruno Haible <bruno@clisp.org>
|
||||
|
||||
Don't use 'register' storage-class specifier in C++ output code.
|
||||
|
||||
@@ -1169,7 +1169,20 @@ output_keyword_entry (KeywordExt *temp, int stringpool_index, const char *indent
|
||||
if (option[TYPE])
|
||||
printf ("{");
|
||||
if (option[SHAREDLIB])
|
||||
printf ("(int)(long)&((struct %s_t *)0)->%s_str%d",
|
||||
/* How to determine a certain offset in stringpool at compile time?
|
||||
- The standard way would be to use the 'offsetof' macro. But it is only
|
||||
defined in <stddef.h>, and <stddef.h> is not among the prerequisite
|
||||
header files that the user must #include.
|
||||
- The next best way would be to take the address and cast to 'intptr_t'
|
||||
or 'uintptr_t'. But these types are only defined in <stdint.h>, and
|
||||
<stdint.h> is not among the prerequisite header files that the user
|
||||
must #include.
|
||||
- The next best approximation of 'uintptr_t' is 'size_t'. It is defined
|
||||
in the prerequisite header <string.h>.
|
||||
- The types 'long' and 'unsigned long' do work as well, but on 64-bit
|
||||
native Windows platforms, they don't have the same size as pointers
|
||||
and therefore generate warnings. */
|
||||
printf ("(int)(size_t)&((struct %s_t *)0)->%s_str%d",
|
||||
option.get_stringpool_name (), option.get_stringpool_name (),
|
||||
stringpool_index);
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user