diff options
author | Bruno Haible <bruno@clisp.org> | 2016-11-26 02:54:25 +0100 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2016-11-26 02:54:25 +0100 |
commit | b468e3aae05d176dbb4b5cdc5820b80b1ed420b9 (patch) | |
tree | c8a6088e645bfa8bd185cbdea151d43566e195f4 | |
parent | baf89d87f0d94b83e7764569da9d84dd36f82ba9 (diff) | |
download | gperf-b468e3aae05d176dbb4b5cdc5820b80b1ed420b9.tar.gz |
Avoid warning in output code on 64-bit native Windows platforms.
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | src/output.cc | 15 |
2 files changed, 23 insertions, 1 deletions
@@ -1,5 +1,14 @@ 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. * src/output.cc (register_scs): New variable. (Output::Output): Initialize it. diff --git a/src/output.cc b/src/output.cc index c6eef39..1ec5d39 100644 --- a/src/output.cc +++ b/src/output.cc @@ -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 |