-#define add_wch(c) wadd_wch(stdscr,c)
-#define add_wchnstr(str,n) wadd_wchnstr(stdscr,str,n)
-#define add_wchstr(str) wadd_wchstr(stdscr,str)
-#define addnwstr(wstr,n) waddnwstr(stdscr,wstr,n)
-#define addwstr(wstr) waddwstr(stdscr,wstr)
-#define bkgrnd(c) wbkgrnd(stdscr,c)
-#define bkgrndset(c) wbkgrndset(stdscr,c)
-#define border_set(l,r,t,b,tl,tr,bl,br) wborder_set(stdscr,l,r,t,b,tl,tr,bl,br)
-#define box_set(w,v,h) wborder_set(w,v,v,h,h,0,0,0,0)
-#define echo_wchar(c) wecho_wchar(stdscr,c)
-#define get_wch(c) wget_wch(stdscr,c)
-#define get_wstr(t) wget_wstr(stdscr,t)
-#define getbkgrnd(wch) wgetbkgrnd(stdscr,wch)
-#define getn_wstr(t,n) wgetn_wstr(stdscr,t,n)
-#define hline_set(c,n) whline_set(stdscr,c,n)
-#define in_wch(c) win_wch(stdscr,c)
-#define in_wchnstr(c,n) win_wchnstr(stdscr,c,n)
-#define in_wchstr(c) win_wchstr(stdscr,c)
-#define innwstr(c,n) winnwstr(stdscr,c,n)
-#define ins_nwstr(t,n) wins_nwstr(stdscr,t,n)
-#define ins_wch(c) wins_wch(stdscr,c)
-#define ins_wstr(t) wins_wstr(stdscr,t)
-#define inwstr(c) winwstr(stdscr,c)
-#define vid_attr(a,pair,opts) vidattr(a)
-#define vline_set(c,n) wvline_set(stdscr,c,n)
-#define wadd_wchstr(win,str) wadd_wchnstr(win,str,-1)
-#define waddwstr(win,wstr) waddnwstr(win,wstr,-1)
-#define wattr_set(win,a,p,opts) ((win)->_attrs = (((a) & ~A_COLOR) | COLOR_PAIR(p)), OK)
-#define wget_wstr(w,t) wgetn_wstr(w,t,-1)
-#define wgetbkgrnd(win,wch) (*wch = win->_bkgrnd, OK)
-#define win_wchstr(w,c) win_wchnstr(w,c,-1)
-#define wins_wstr(w,t) wins_nwstr(w,t,-1)
-
-#define mvadd_wch(y,x,c) mvwadd_wch(stdscr,y,x,c)
-#define mvadd_wchnstr(y,x,s,n) mvwadd_wchnstr(stdscr,y,x,s,n)
-#define mvadd_wchstr(y,x,s) mvwadd_wchstr(stdscr,y,x,s)
-#define mvaddnwstr(y,x,wstr,n) mvwaddnwstr(stdscr,y,x,wstr,n)
-#define mvaddwstr(y,x,wstr) mvwaddwstr(stdscr,y,x,wstr)
-#define mvget_wch(y,x,c) mvwget_wch(stdscr,y,x,c)
-#define mvget_wstr(y,x,t) mvwget_wstr(stdscr,y,x,t)
-#define mvgetn_wstr(y,x,t,n) mvwgetn_wstr(stdscr,y,x,t,n)
-#define mvhline_set(y,x,c,n) mvwhline_set(stdscr,y,x,c,n)
-#define mvin_wch(y,x,c) mvwin_wch(stdscr,y,x,c)
-#define mvin_wchnstr(y,x,c,n) mvwin_wchnstr(stdscr,y,x,c,n)
-#define mvin_wchstr(y,x,c) mvwin_wchstr(stdscr,y,x,c)
-#define mvinnwstr(y,x,c,n) mvwinnwstr(stdscr,y,x,c,n)
-#define mvins_nwstr(y,x,t,n) mvwins_nwstr(stdscr,y,x,t,n)
-#define mvins_wch(y,x,c) mvwins_wch(stdscr,y,x,c)
-#define mvins_wstr(y,x,t) mvwins_wstr(stdscr,y,x,t)
-#define mvinwstr(y,x,c) mvwinwstr(stdscr,y,x,c)
-#define mvvline_set(y,x,c,n) mvwvline_set(stdscr,y,x,c,n)
-
-#define mvwadd_wch(win,y,x,c) (wmove(win,y,x) == ERR ? ERR : wadd_wch(win,c))
-#define mvwadd_wchnstr(win,y,x,s,n) (wmove(win,y,x) == ERR ? ERR : wadd_wchnstr(win,s,n))
-#define mvwadd_wchstr(win,y,x,s) (wmove(win,y,x) == ERR ? ERR : wadd_wchstr(win,s))
-#define mvwaddnwstr(win,y,x,wstr,n) (wmove(win,y,x) == ERR ? ERR : waddnwstr(win,wstr,n))
-#define mvwaddwstr(win,y,x,wstr) (wmove(win,y,x) == ERR ? ERR : waddwstr(win,wstr))
-#define mvwget_wch(win,y,x,c) (wmove(win,y,x) == ERR ? ERR : wget_wch(win,c))
-#define mvwget_wstr(win,y,x,t) (wmove(win,y,x) == ERR ? ERR : wget_wstr(win,t))
-#define mvwgetn_wstr(win,y,x,t,n) (wmove(win,y,x) == ERR ? ERR : wgetn_wstr(win,t,n))
-#define mvwhline_set(win,y,x,c,n) (wmove(win,y,x) == ERR ? ERR : whline_set(win,c,n))
-#define mvwin_wch(win,y,x,c) (wmove(win,y,x) == ERR ? ERR : win_wch(win,c))
-#define mvwin_wchnstr(win,y,x,c,n) (wmove(win,y,x) == ERR ? ERR : win_wchnstr(win,c,n))
-#define mvwin_wchstr(win,y,x,c) (wmove(win,y,x) == ERR ? ERR : win_wchstr(win,c))
-#define mvwinnwstr(win,y,x,c,n) (wmove(win,y,x) == ERR ? ERR : winnwstr(win,c,n))
-#define mvwins_nwstr(win,y,x,t,n) (wmove(win,y,x) == ERR ? ERR : wins_nwstr(win,t,n))
-#define mvwins_wch(win,y,x,c) (wmove(win,y,x) == ERR ? ERR : wins_wch(win,c))
-#define mvwins_wstr(win,y,x,t) (wmove(win,y,x) == ERR ? ERR : wins_wstr(win,t))
-#define mvwinwstr(win,y,x,c) (wmove(win,y,x) == ERR ? ERR : winwstr(win,c))
-#define mvwvline_set(win,y,x,c,n) (wmove(win,y,x) == ERR ? ERR : wvline_set(win,c,n))
-
-#endif /* _XOPEN_SOURCE_EXTENDED */
+#define add_wch(c) wadd_wch(stdscr,(c))
+#define add_wchnstr(str,n) wadd_wchnstr(stdscr,(str),(n))
+#define add_wchstr(str) wadd_wchstr(stdscr,(str))
+#define addnwstr(wstr,n) waddnwstr(stdscr,(wstr),(n))
+#define addwstr(wstr) waddwstr(stdscr,(wstr))
+#define bkgrnd(c) wbkgrnd(stdscr,(c))
+#define bkgrndset(c) wbkgrndset(stdscr,(c))
+#define border_set(l,r,t,b,tl,tr,bl,br) wborder_set(stdscr,(l),(r),(t),(b),tl,tr,bl,br)
+#define box_set(w,v,h) wborder_set((w),(v),(v),(h),(h),0,0,0,0)
+#define echo_wchar(c) wecho_wchar(stdscr,(c))
+#define get_wch(c) wget_wch(stdscr,(c))
+#define get_wstr(t) wget_wstr(stdscr,(t))
+#define getbkgrnd(wch) wgetbkgrnd(stdscr,(wch))
+#define getn_wstr(t,n) wgetn_wstr(stdscr,(t),(n))
+#define hline_set(c,n) whline_set(stdscr,(c),(n))
+#define in_wch(c) win_wch(stdscr,(c))
+#define in_wchnstr(c,n) win_wchnstr(stdscr,(c),(n))
+#define in_wchstr(c) win_wchstr(stdscr,(c))
+#define innwstr(c,n) winnwstr(stdscr,(c),(n))
+#define ins_nwstr(t,n) wins_nwstr(stdscr,(t),(n))
+#define ins_wch(c) wins_wch(stdscr,(c))
+#define ins_wstr(t) wins_wstr(stdscr,(t))
+#define inwstr(c) winwstr(stdscr,(c))
+#define vline_set(c,n) wvline_set(stdscr,(c),(n))
+#define wadd_wchstr(win,str) wadd_wchnstr((win),(str),-1)
+#define waddwstr(win,wstr) waddnwstr((win),(wstr),-1)
+#define wget_wstr(w,t) wgetn_wstr((w),(t),-1)
+#define win_wchstr(w,c) win_wchnstr((w),(c),-1)
+#define wins_wstr(w,t) wins_nwstr((w),(t),-1)
+
+#if !NCURSES_OPAQUE
+#define wgetbkgrnd(win,wch) (NCURSES_OK_ADDR(wch) ? ((win) ? (*(wch) = (win)->_bkgrnd) : *(wch), OK) : ERR)
+#endif
+
+#define mvadd_wch(y,x,c) mvwadd_wch(stdscr,(y),(x),(c))
+#define mvadd_wchnstr(y,x,s,n) mvwadd_wchnstr(stdscr,(y),(x),(s),(n))
+#define mvadd_wchstr(y,x,s) mvwadd_wchstr(stdscr,(y),(x),(s))
+#define mvaddnwstr(y,x,wstr,n) mvwaddnwstr(stdscr,(y),(x),(wstr),(n))
+#define mvaddwstr(y,x,wstr) mvwaddwstr(stdscr,(y),(x),(wstr))
+#define mvget_wch(y,x,c) mvwget_wch(stdscr,(y),(x),(c))
+#define mvget_wstr(y,x,t) mvwget_wstr(stdscr,(y),(x),(t))
+#define mvgetn_wstr(y,x,t,n) mvwgetn_wstr(stdscr,(y),(x),(t),(n))
+#define mvhline_set(y,x,c,n) mvwhline_set(stdscr,(y),(x),(c),(n))
+#define mvin_wch(y,x,c) mvwin_wch(stdscr,(y),(x),(c))
+#define mvin_wchnstr(y,x,c,n) mvwin_wchnstr(stdscr,(y),(x),(c),(n))
+#define mvin_wchstr(y,x,c) mvwin_wchstr(stdscr,(y),(x),(c))
+#define mvinnwstr(y,x,c,n) mvwinnwstr(stdscr,(y),(x),(c),(n))
+#define mvins_nwstr(y,x,t,n) mvwins_nwstr(stdscr,(y),(x),(t),(n))
+#define mvins_wch(y,x,c) mvwins_wch(stdscr,(y),(x),(c))
+#define mvins_wstr(y,x,t) mvwins_wstr(stdscr,(y),(x),(t))
+#define mvinwstr(y,x,c) mvwinwstr(stdscr,(y),(x),(c))
+#define mvvline_set(y,x,c,n) mvwvline_set(stdscr,(y),(x),(c),(n))
+
+#define mvwadd_wch(win,y,x,c) (wmove(win,(y),(x)) == ERR ? ERR : wadd_wch((win),(c)))
+#define mvwadd_wchnstr(win,y,x,s,n) (wmove(win,(y),(x)) == ERR ? ERR : wadd_wchnstr((win),(s),(n)))
+#define mvwadd_wchstr(win,y,x,s) (wmove(win,(y),(x)) == ERR ? ERR : wadd_wchstr((win),(s)))
+#define mvwaddnwstr(win,y,x,wstr,n) (wmove(win,(y),(x)) == ERR ? ERR : waddnwstr((win),(wstr),(n)))
+#define mvwaddwstr(win,y,x,wstr) (wmove(win,(y),(x)) == ERR ? ERR : waddwstr((win),(wstr)))
+#define mvwget_wch(win,y,x,c) (wmove(win,(y),(x)) == ERR ? ERR : wget_wch((win),(c)))
+#define mvwget_wstr(win,y,x,t) (wmove(win,(y),(x)) == ERR ? ERR : wget_wstr((win),(t)))
+#define mvwgetn_wstr(win,y,x,t,n) (wmove(win,(y),(x)) == ERR ? ERR : wgetn_wstr((win),(t),(n)))
+#define mvwhline_set(win,y,x,c,n) (wmove(win,(y),(x)) == ERR ? ERR : whline_set((win),(c),(n)))
+#define mvwin_wch(win,y,x,c) (wmove(win,(y),(x)) == ERR ? ERR : win_wch((win),(c)))
+#define mvwin_wchnstr(win,y,x,c,n) (wmove(win,(y),(x)) == ERR ? ERR : win_wchnstr((win),(c),(n)))
+#define mvwin_wchstr(win,y,x,c) (wmove(win,(y),(x)) == ERR ? ERR : win_wchstr((win),(c)))
+#define mvwinnwstr(win,y,x,c,n) (wmove(win,(y),(x)) == ERR ? ERR : winnwstr((win),(c),(n)))
+#define mvwins_nwstr(win,y,x,t,n) (wmove(win,(y),(x)) == ERR ? ERR : wins_nwstr((win),(t),(n)))
+#define mvwins_wch(win,y,x,c) (wmove(win,(y),(x)) == ERR ? ERR : wins_wch((win),(c)))
+#define mvwins_wstr(win,y,x,t) (wmove(win,(y),(x)) == ERR ? ERR : wins_wstr((win),(t)))
+#define mvwinwstr(win,y,x,c) (wmove(win,(y),(x)) == ERR ? ERR : winwstr((win),(c)))
+#define mvwvline_set(win,y,x,c,n) (wmove(win,(y),(x)) == ERR ? ERR : wvline_set((win),(c),(n)))
+
+#endif /* NCURSES_NOMACROS */
+
+#if defined(TRACE) || defined(NCURSES_TEST)
+extern NCURSES_EXPORT(const char *) _nc_viswbuf(const wchar_t *);
+extern NCURSES_EXPORT(const char *) _nc_viswibuf(const wint_t *);
+#endif
+
+#endif /* NCURSES_WIDECHAR */