Commit 560c4ab1 authored by Ken Brown's avatar Ken Brown

Fix compiler warnings in Cygwin-w32 build

* src/conf_post.h (DebPrint) [!EMACSDEBUG]: Add empty do-while
loop to avoid compiler warnings about empty body of 'if'
statement.

* src/image.c [HAVE_NTGUI] (DefaultDepthOfScreen): Disable unused
macro.
(x_create_bitmap_from_data): Declare 'frame'.
(x_create_bitmap_from_file): Don't declare unused variable
'dpyinfo'.

* src/lisp.h (AUTO_STRING_WITH_LEN): Avoid initialization to
prevent "jump-misses-init" compiler warnings.

* src/w32fns.c (check_w32_winkey_state): Define and use only if
WINDOWSNT.
(Fx_show_tip): Declare 'f'.
(Fx_file_dialog): Declare 'filter_a' only if not NTGUI_UNICODE.
(w32_strerror): Use format specifier %d for sprintf argument of
type int.
(emacs_abort): Cast sprintf argument of type DWORD to unsigned
int, and use format specifier %x, for compatibility with Cygwin.
(unicode_append_menu) [NTGUI_UNICODE]:
* src/w32menu.c [NTGUI_UNICODE] (get_menu_item_info)
(set_menu_item_info, unicode_append_menu)
(unicode_message_box):
* src/menu.c [NTGUI_UNICODE] (unicode_append_menu): Define as
functions rather than macros to avoid "address will always
evaluate as true" compiler warnings.

* src/w32font.c (w32_to_x_charset): Use format specifier %d for
sprintf argument of type int.

* src/w32term.c (x_draw_glyphless_glyph_string_foreground): Cast
sprintf argument of type int to unsigned int to match %X format
specifier.
(w32_scroll_bar_handle_click):
(w32_horizontal_scroll_bar_handle_click): Declare 'f'.

* src/w32term.h (FRAME_DISPLAY_INFO): Explicitly discard unused
argument.
parent d4c1535c
......@@ -211,7 +211,8 @@ You lose; /* Emacs for DOS must be compiled with DJGPP */
extern void _DebPrint (const char *fmt, ...);
# define DebPrint(stuff) _DebPrint stuff
# else
# define DebPrint(stuff)
/* Avoid compiler warnings about empty body of 'if' statement. */
# define DebPrint(stuff) do {} while (false)
# endif
#endif
......
......@@ -80,7 +80,9 @@ typedef struct w32_bitmap_record Bitmap_Record;
#define PIX_MASK_DRAW 1
#define x_defined_color w32_defined_color
#if 0 /* unused */
#define DefaultDepthOfScreen(screen) (one_w32_display_info.n_cbits)
#endif
#endif /* HAVE_NTGUI */
......@@ -223,6 +225,7 @@ x_create_bitmap_from_data (struct frame *f, char *bits, unsigned int width, unsi
#endif /* HAVE_X_WINDOWS */
#ifdef HAVE_NTGUI
Lisp_Object frame UNINIT; /* The value is not used. */
Pixmap bitmap;
bitmap = CreateBitmap (width, height,
FRAME_DISPLAY_INFO (XFRAME (frame))->n_planes,
......@@ -272,9 +275,9 @@ x_create_bitmap_from_file (struct frame *f, Lisp_Object file)
{
#ifdef HAVE_NTGUI
return -1; /* W32_TODO : bitmap support */
#endif /* HAVE_NTGUI */
#else
Display_Info *dpyinfo = FRAME_DISPLAY_INFO (f);
#endif
#ifdef HAVE_NS
ptrdiff_t id;
......
......@@ -4634,8 +4634,10 @@ enum
STR's value is not necessarily copied. The resulting Lisp string
should not be modified or made visible to user code. */
/* Avoid initializing NAME to prevent "jump-misses-init" compiler
warnings. */
#define AUTO_STRING_WITH_LEN(name, str, len) \
Lisp_Object name = \
Lisp_Object name; name = \
(USE_STACK_STRING \
? (make_lisp_ptr \
((&(union Aligned_String) \
......
......@@ -42,11 +42,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#endif /* HAVE_WINDOW_SYSTEM */
#ifdef HAVE_NTGUI
# ifdef NTGUI_UNICODE
# define unicode_append_menu AppendMenuW
# else /* !NTGUI_UNICODE */
extern AppendMenuW_Proc unicode_append_menu;
# endif /* NTGUI_UNICODE */
#endif /* HAVE_NTGUI */
#include "menu.h"
......
......@@ -186,11 +186,7 @@ MonitorFromWindow_Proc monitor_from_window_fn = NULL;
EnumDisplayMonitors_Proc enum_display_monitors_fn = NULL;
GetTitleBarInfo_Proc get_title_bar_info_fn = NULL;
#ifdef NTGUI_UNICODE
#define unicode_append_menu AppendMenuW
#else /* !NTGUI_UNICODE */
extern AppendMenuW_Proc unicode_append_menu;
#endif /* NTGUI_UNICODE */
/* Flag to selectively ignore WM_IME_CHAR messages. */
static int ignore_ime_char = 0;
......@@ -2406,6 +2402,7 @@ hook_w32_key (int hook, int modifier, int vkey)
}
}
#ifdef WINDOWSNT
/* Check the current Win key pressed state. */
int
check_w32_winkey_state (int vkey)
......@@ -2433,6 +2430,7 @@ check_w32_winkey_state (int vkey)
}
return 0;
}
#endif /* WINDOWSNT */
/* Reset the keyboard hook state. Locking the workstation with Win-L
leaves the Win key(s) "down" from the hook's point of view - the
......@@ -2623,8 +2621,10 @@ modifier_set (int vkey)
else
return (GetKeyState (vkey) & 0x1);
}
#ifdef WINDOWSNT
if (w32_kbdhook_active && (vkey == VK_LWIN || vkey == VK_RWIN))
return check_w32_winkey_state (vkey);
#endif
if (!modifiers_recorded)
return (GetKeyState (vkey) & 0x8000);
......@@ -7043,6 +7043,7 @@ Text larger than the specified size is clipped. */)
/* Create a frame for the tooltip, and record it in the global
variable tip_frame. */
struct frame *f; /* The value is unused. */
if (NILP (tip_frame = x_create_tip_frame (FRAME_DISPLAY_INFO (f), parms)))
{
/* Creating the tip frame failed. */
......@@ -7288,7 +7289,9 @@ value of DIR as in previous invocations; this is standard Windows behavior. */)
{
/* Filter index: 1: All Files, 2: Directories only */
static const wchar_t filter_w[] = L"All Files (*.*)\0*.*\0Directories\0*|*\0";
#ifndef NTGUI_UNICODE
static const char filter_a[] = "All Files (*.*)\0*.*\0Directories\0*|*\0";
#endif
Lisp_Object filename = default_filename;
struct frame *f = SELECTED_FRAME ();
......@@ -8962,7 +8965,7 @@ w32_strerror (int error_no)
--ret;
buf[ret] = '\0';
if (!ret)
sprintf (buf, "w32 error %u", error_no);
sprintf (buf, "w32 error %d", error_no);
return buf;
}
......@@ -10331,8 +10334,8 @@ emacs_abort (void)
but not on Windows 7. addr2line doesn't mind a missing
"0x", but will be confused by an extra one. */
if (except_addr)
sprintf (buf, "\r\nException 0x%lx at this address:\r\n%p\r\n",
except_code, except_addr);
sprintf (buf, "\r\nException 0x%x at this address:\r\n%p\r\n",
(unsigned int) except_code, except_addr);
if (stderr_fd >= 0)
{
if (except_addr)
......
......@@ -1747,7 +1747,7 @@ w32_to_x_charset (int fncharset, char *matching)
default:
/* Encode numerical value of unknown charset. */
sprintf (buf, "*-#%u", fncharset);
sprintf (buf, "*-#%d", fncharset);
return buf;
}
......@@ -1834,7 +1834,7 @@ w32_to_x_charset (int fncharset, char *matching)
/* If no match, encode the numeric value. */
if (!best_match)
{
sprintf (buf, "*-#%u", fncharset);
sprintf (buf, "*-#%d", fncharset);
return buf;
}
......
......@@ -77,10 +77,10 @@ typedef int (WINAPI * MessageBoxW_Proc) (
IN UINT type);
#ifdef NTGUI_UNICODE
#define get_menu_item_info GetMenuItemInfoA
#define set_menu_item_info SetMenuItemInfoA
#define unicode_append_menu AppendMenuW
#define unicode_message_box MessageBoxW
GetMenuItemInfoA_Proc get_menu_item_info = GetMenuItemInfoA;
SetMenuItemInfoA_Proc set_menu_item_info = SetMenuItemInfoA;
AppendMenuW_Proc unicode_append_menu = AppendMenuW;
MessageBoxW_Proc unicode_message_box = MessageBoxW;
#else /* !NTGUI_UNICODE */
GetMenuItemInfoA_Proc get_menu_item_info = NULL;
SetMenuItemInfoA_Proc set_menu_item_info = NULL;
......
......@@ -1434,7 +1434,7 @@ x_draw_glyphless_glyph_string_foreground (struct glyph_string *s)
{
sprintf ((char *) buf, "%0*X",
glyph->u.glyphless.ch < 0x10000 ? 4 : 6,
glyph->u.glyphless.ch);
(unsigned int) glyph->u.glyphless.ch);
str = buf;
}
......@@ -4198,6 +4198,7 @@ w32_scroll_bar_handle_click (struct scroll_bar *bar, W32Msg *msg,
y = si.nPos;
bar->dragging = 0;
struct frame *f; /* Value is not used. */
FRAME_DISPLAY_INFO (f)->last_mouse_scroll_bar_pos = msg->msg.wParam;
switch (sb_event)
......@@ -4313,6 +4314,7 @@ w32_horizontal_scroll_bar_handle_click (struct scroll_bar *bar, W32Msg *msg,
y = si.nMax - si.nPage;
bar->dragging = 0;
struct frame *f; /* Value is not used. */
FRAME_DISPLAY_INFO (f)->last_mouse_scroll_bar_pos = msg->msg.wParam;
switch (sb_event)
......
......@@ -399,7 +399,7 @@ extern struct w32_output w32term_display;
#define FRAME_BASELINE_OFFSET(f) ((f)->output_data.w32->baseline_offset)
/* This gives the w32_display_info structure for the display F is on. */
#define FRAME_DISPLAY_INFO(f) (&one_w32_display_info)
#define FRAME_DISPLAY_INFO(f) ((void) (f), (&one_w32_display_info))
/* This is the `Display *' which frame F is on. */
#define FRAME_X_DISPLAY(f) (0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment