summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2020-03-08 16:49:06 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2020-03-08 16:49:06 (GMT)
commit7b507ce5d4879deb3479ee07dc39e2f7b9bb86c2 (patch)
tree32a65429d4b799e113c9d5517ac2974bd2359799
parentd02acd85db6c30b28e7c2e98e46955076d44c406 (diff)
downloadtk-7b507ce5d4879deb3479ee07dc39e2f7b9bb86c2.zip
tk-7b507ce5d4879deb3479ee07dc39e2f7b9bb86c2.tar.gz
tk-7b507ce5d4879deb3479ee07dc39e2f7b9bb86c2.tar.bz2
Instroduce TCL_UNUSED() macro, and use to make more -Wextra warnings disappear.
-rw-r--r--generic/tkInt.h15
-rw-r--r--generic/tkUtil.c39
-rw-r--r--macosx/tkMacOSXMenu.c40
-rw-r--r--macosx/tkMacOSXMenus.c16
-rw-r--r--macosx/tkMacOSXWindowEvent.c16
-rw-r--r--macosx/tkMacOSXWm.c10
6 files changed, 81 insertions, 55 deletions
diff --git a/generic/tkInt.h b/generic/tkInt.h
index 7cbe434..8c7127f 100644
--- a/generic/tkInt.h
+++ b/generic/tkInt.h
@@ -58,6 +58,21 @@
# endif
#endif
+#ifndef JOIN
+# define JOIN(a,b) JOIN1(a,b)
+# define JOIN1(a,b) a##b
+#endif
+
+#ifndef TCL_UNUSED
+# if defined(__cplusplus)
+# define TCL_UNUSED(T) T
+# elif defined(__GNUC__) && (__GNUC__ > 2)
+# define TCL_UNUSED(T) T JOIN(dummy, __LINE__) __attribute__((unused))
+# else
+# define TCL_UNUSED(T) T JOIN(dummy, __LINE__)
+# endif
+#endif
+
#ifndef TkSizeT
# if TCL_MAJOR_VERSION > 8
# define TkSizeT size_t
diff --git a/generic/tkUtil.c b/generic/tkUtil.c
index 77adc6c..009adda 100644
--- a/generic/tkUtil.c
+++ b/generic/tkUtil.c
@@ -48,7 +48,7 @@ int
TkStateParseProc(
ClientData clientData, /* some flags.*/
Tcl_Interp *interp, /* Used for reporting errors. */
- Tk_Window tkwin, /* Window containing canvas widget. */
+ TCL_UNUSED(Tk_Window), /* Window containing canvas widget. */
const char *value, /* Value of option. */
char *widgRec, /* Pointer to record for item. */
int offset) /* Offset into item. */
@@ -58,7 +58,6 @@ TkStateParseProc(
size_t length;
Tcl_Obj *msgObj;
Tk_State *statePtr = (Tk_State *) (widgRec + offset);
- (void)tkwin;
if (value == NULL || *value == 0) {
*statePtr = TK_STATE_NULL;
@@ -126,18 +125,15 @@ TkStateParseProc(
const char *
TkStatePrintProc(
- ClientData dummy, /* Ignored. */
- Tk_Window tkwin, /* Window containing canvas widget. */
+ TCL_UNUSED(void *), /* Ignored. */
+ TCL_UNUSED(Tk_Window), /* Window containing canvas widget. */
char *widgRec, /* Pointer to record for item. */
int offset, /* Offset into item. */
- Tcl_FreeProc **freeProcPtr) /* Pointer to variable to fill in with
+ TCL_UNUSED(Tcl_FreeProc **)) /* Pointer to variable to fill in with
* information about how to reclaim storage
* for return string. */
{
Tk_State *statePtr = (Tk_State *) (widgRec + offset);
- (void)dummy;
- (void)tkwin;
- (void)freeProcPtr;
switch (*statePtr) {
case TK_STATE_NORMAL:
@@ -173,9 +169,9 @@ TkStatePrintProc(
int
TkOrientParseProc(
- ClientData dummy, /* some flags.*/
+ TCL_UNUSED(void *), /* some flags.*/
Tcl_Interp *interp, /* Used for reporting errors. */
- Tk_Window tkwin, /* Window containing canvas widget. */
+ TCL_UNUSED(Tk_Window), /* Window containing canvas widget. */
const char *value, /* Value of option. */
char *widgRec, /* Pointer to record for item. */
int offset) /* Offset into item. */
@@ -183,8 +179,6 @@ TkOrientParseProc(
int c;
size_t length;
int *orientPtr = (int *) (widgRec + offset);
- (void)dummy;
- (void)tkwin;
if (value == NULL || *value == 0) {
*orientPtr = 0;
@@ -233,18 +227,15 @@ TkOrientParseProc(
const char *
TkOrientPrintProc(
- ClientData dummy, /* Ignored. */
- Tk_Window tkwin, /* Window containing canvas widget. */
+ TCL_UNUSED(void *), /* Ignored. */
+ TCL_UNUSED(Tk_Window), /* Window containing canvas widget. */
char *widgRec, /* Pointer to record for item. */
int offset, /* Offset into item. */
- Tcl_FreeProc **freeProcPtr) /* Pointer to variable to fill in with
+ TCL_UNUSED(Tcl_FreeProc **)) /* Pointer to variable to fill in with
* information about how to reclaim storage
* for return string. */
{
int *statePtr = (int *) (widgRec + offset);
- (void)dummy;
- (void)tkwin;
- (void)freeProcPtr;
if (*statePtr) {
return "vertical";
@@ -418,16 +409,14 @@ TkOffsetParseProc(
const char *
TkOffsetPrintProc(
- ClientData dummy, /* not used */
- Tk_Window tkwin, /* not used */
+ TCL_UNUSED(void *), /* not used */
+ TCL_UNUSED(Tk_Window), /* not used */
char *widgRec, /* Widget structure record */
int offset, /* Offset of tile in record */
Tcl_FreeProc **freeProcPtr) /* not used */
{
Tk_TSOffset *offsetPtr = (Tk_TSOffset *) (widgRec + offset);
char *p, *q;
- (void)dummy;
- (void)tkwin;
if (offsetPtr->flags & TK_OFFSET_INDEX) {
if (offsetPtr->flags >= INT_MAX) {
@@ -521,16 +510,14 @@ TkPixelParseProc(
const char *
TkPixelPrintProc(
- ClientData dummy, /* not used */
- Tk_Window tkwin, /* not used */
+ TCL_UNUSED(void *), /* not used */
+ TCL_UNUSED(Tk_Window), /* not used */
char *widgRec, /* Widget structure record */
int offset, /* Offset of tile in record */
Tcl_FreeProc **freeProcPtr) /* not used */
{
double *doublePtr = (double *) (widgRec + offset);
char *p = (char *)ckalloc(24);
- (void)dummy;
- (void)tkwin;
Tcl_PrintDouble(NULL, *doublePtr, p);
*freeProcPtr = TCL_DYNAMIC;
diff --git a/macosx/tkMacOSXMenu.c b/macosx/tkMacOSXMenu.c
index 35c0275..7ffc054 100644
--- a/macosx/tkMacOSXMenu.c
+++ b/macosx/tkMacOSXMenu.c
@@ -401,6 +401,7 @@ static int ModifierCharWidth(Tk_Font tkfont);
- (void) menuBeginTracking: (NSNotification *) notification
{
+ (void)notification;
#ifdef TK_MAC_DEBUG_NOTIFICATIONS
TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification);
#endif
@@ -410,6 +411,7 @@ static int ModifierCharWidth(Tk_Font tkfont);
- (void) menuEndTracking: (NSNotification *) notification
{
+ (void)notification;
#ifdef TK_MAC_DEBUG_NOTIFICATIONS
TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification);
#endif
@@ -794,7 +796,7 @@ TkpDestroyMenuEntry(
int
TkpPostMenu(
- Tcl_Interp *interp, /* The interpreter this menu lives in */
+ TCL_UNUSED(Tcl_Interp *), /* The interpreter this menu lives in */
TkMenu *menuPtr, /* The menu we are posting */
int x, int y, /* The screen coordinates where the top left
* corner of the menu, or of the specified
@@ -891,7 +893,7 @@ TkpPostMenu(
int
TkpPostTearoffMenu(
- Tcl_Interp *interp, /* The interpreter this menu lives in */
+ TCL_UNUSED(Tcl_Interp *), /* The interpreter this menu lives in */
TkMenu *menuPtr, /* The menu we are posting */
int x, int y, int index) /* The screen coordinates where the top left
* corner of the menu, or of the specified
@@ -1700,8 +1702,8 @@ TkpMenuThreadInit(void)
void
TkpMenuNotifyToplevelCreate(
- Tcl_Interp *interp, /* The interp the menu lives in. */
- const char *menuName) /* The name of the menu to reconfigure. */
+ TCL_UNUSED(Tcl_Interp *), /* The interp the menu lives in. */
+ TCL_UNUSED(const char *)) /* The name of the menu to reconfigure. */
{
/*
* Nothing to do.
@@ -1729,8 +1731,8 @@ TkpMenuNotifyToplevelCreate(
void
TkpInitializeMenuBindings(
- Tcl_Interp *interp, /* The interpreter to set. */
- Tk_BindingTable bindingTable)
+ TCL_UNUSED(Tcl_Interp *), /* The interpreter to set. */
+ TCL_UNUSED(Tk_BindingTable))
/* The table to add to. */
{
/*
@@ -1783,17 +1785,17 @@ TkpComputeMenubarGeometry(
void
TkpDrawMenuEntry(
- TkMenuEntry *mePtr, /* The entry to draw */
- Drawable d, /* What to draw into */
- Tk_Font tkfont, /* Precalculated font for menu */
- const Tk_FontMetrics *menuMetricsPtr,
+ TCL_UNUSED(TkMenuEntry *), /* The entry to draw */
+ TCL_UNUSED(Drawable), /* What to draw into */
+ TCL_UNUSED(Tk_Font), /* Precalculated font for menu */
+ TCL_UNUSED(const Tk_FontMetrics *),
/* Precalculated metrics for menu */
- int x, /* X-coordinate of topleft of entry */
- int y, /* Y-coordinate of topleft of entry */
- int width, /* Width of the entry rectangle */
- int height, /* Height of the current rectangle */
- int strictMotif, /* Boolean flag */
- int drawArrow) /* Whether or not to draw the cascade arrow
+ TCL_UNUSED(int), /* X-coordinate of topleft of entry */
+ TCL_UNUSED(int), /* Y-coordinate of topleft of entry */
+ TCL_UNUSED(int), /* Width of the entry rectangle */
+ TCL_UNUSED(int), /* Height of the current rectangle */
+ TCL_UNUSED(int), /* Boolean flag */
+ TCL_UNUSED(int)) /* Whether or not to draw the cascade arrow
* for cascade items. */
{
}
@@ -1842,7 +1844,7 @@ TkMacOSXPreprocessMenu(void)
int
TkMacOSXUseMenuID(
- short macID) /* The id to take out of the table */
+ TCL_UNUSED(short)) /* The id to take out of the table */
{
return TCL_OK;
}
@@ -1865,8 +1867,8 @@ TkMacOSXUseMenuID(
int
TkMacOSXDispatchMenuEvent(
- int menuID, /* The menu id of the menu we are invoking */
- int index) /* The one-based index of the item that was
+ TCL_UNUSED(int), /* The menu id of the menu we are invoking */
+ TCL_UNUSED(int)) /* The one-based index of the item that was
* selected. */
{
return TCL_ERROR;
diff --git a/macosx/tkMacOSXMenus.c b/macosx/tkMacOSXMenus.c
index 82bcda7..d6d3185 100644
--- a/macosx/tkMacOSXMenus.c
+++ b/macosx/tkMacOSXMenus.c
@@ -199,6 +199,8 @@ static Tcl_Obj * GetWidgetDemoPath(Tcl_Interp *interp);
- (void) orderFrontStandardAboutPanel: (id) sender
{
+ (void)sender;
+
if (!_eventInterp || !Tcl_FindCommand(_eventInterp, "tkAboutDialog",
NULL, 0) || (GetCurrentEventKeyModifiers() & optionKey)) {
TkAboutDlg();
@@ -231,6 +233,8 @@ static Tcl_Obj * GetWidgetDemoPath(Tcl_Interp *interp);
- (void) tkSource: (id) sender
{
+ (void)sender;
+
if (_eventInterp) {
if (Tcl_EvalEx(_eventInterp, "tk_getOpenFile -filetypes {"
"{{TCL Scripts} {.tcl} TEXT} {{Text Files} {} TEXT}}",
@@ -256,6 +260,8 @@ static Tcl_Obj * GetWidgetDemoPath(Tcl_Interp *interp);
- (void) tkDemo: (id) sender
{
+ (void)sender;
+
if (_eventInterp) {
Tcl_Obj *path = GetWidgetDemoPath(_eventInterp);
@@ -281,6 +287,8 @@ static Tcl_Obj * GetWidgetDemoPath(Tcl_Interp *interp);
- (BOOL) validateUserInterfaceItem: (id <NSValidatedUserInterfaceItem>) anItem
{
+ (void)anItem;
+
return YES;
}
@@ -355,9 +363,9 @@ GetWidgetDemoPath(
void
TkMacOSXHandleMenuSelect(
- short theMenu,
- unsigned short theItem,
- int optionKeyPressed)
+ TCL_UNUSED(short),
+ TCL_UNUSED(unsigned short),
+ TCL_UNUSED(int))
{
Tcl_Panic("TkMacOSXHandleMenuSelect: Obsolete, no more Carbon!");
}
@@ -380,7 +388,7 @@ TkMacOSXHandleMenuSelect(
void
TkMacOSXInitMenus(
- Tcl_Interp *interp)
+ TCL_UNUSED(Tcl_Interp *))
{
[NSApp _setupMenus];
}
diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c
index aca502d..5ecadb9 100644
--- a/macosx/tkMacOSXWindowEvent.c
+++ b/macosx/tkMacOSXWindowEvent.c
@@ -153,6 +153,7 @@ extern NSString *NSWindowDidOrderOffScreenNotification;
- (NSSize)window:(NSWindow *)window
willUseFullScreenContentSize:(NSSize)proposedSize
{
+ (void)window;
/*
* We don't need to change the proposed size, but we do need to implement
* this method. Otherwise the full screen window will be sized to the
@@ -290,6 +291,8 @@ extern NSString *NSWindowDidOrderOffScreenNotification;
- (void) applicationActivate: (NSNotification *) notification
{
+ (void)notification;
+
#ifdef TK_MAC_DEBUG_NOTIFICATIONS
TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification);
#endif
@@ -314,6 +317,8 @@ extern NSString *NSWindowDidOrderOffScreenNotification;
- (void) applicationDeactivate: (NSNotification *) notification
{
+ (void)notification;
+
#ifdef TK_MAC_DEBUG_NOTIFICATIONS
TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification);
#endif
@@ -322,6 +327,9 @@ extern NSString *NSWindowDidOrderOffScreenNotification;
- (BOOL)applicationShouldHandleReopen:(NSApplication *)sender
hasVisibleWindows:(BOOL)flag
{
+ (void)sender;
+ (void)flag;
+
/*
* Allowing the default response means that withdrawn windows will get
* displayed on the screen with unresponsive title buttons. We don't
@@ -354,6 +362,8 @@ extern NSString *NSWindowDidOrderOffScreenNotification;
- (void) displayChanged: (NSNotification *) notification
{
+ (void)notification;
+
#ifdef TK_MAC_DEBUG_NOTIFICATIONS
TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification);
#endif
@@ -889,7 +899,7 @@ ExposeRestrictProc(
static Tk_RestrictAction
ConfigureRestrictProc(
- ClientData arg,
+ TCL_UNUSED(void *),
XEvent *eventPtr)
{
return (eventPtr->type==ConfigureNotify ? TK_PROCESS_EVENT : TK_DEFER_EVENT);
@@ -926,6 +936,7 @@ RedisplayView(
{
const NSRect *rectsBeingDrawn;
NSInteger rectsBeingDrawnCount;
+ (void)rect;
#ifdef TK_MAC_DEBUG_DRAWING
TkWindow *winPtr = TkMacOSXGetTkWindow([self window]);
@@ -1152,6 +1163,8 @@ RedisplayView(
int x, y;
TkWindow *winPtr = TkMacOSXGetTkWindow([self window]);
Tk_Window tkwin = (Tk_Window) winPtr;
+ (void)sender;
+
if (!winPtr){
return;
}
@@ -1196,6 +1209,7 @@ RedisplayView(
- (void) keyDown: (NSEvent *) theEvent
{
+ (void)theEvent;
#ifdef TK_MAC_DEBUG_EVENTS
TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, theEvent);
#endif
diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c
index 4e53282..fac8e0c 100644
--- a/macosx/tkMacOSXWm.c
+++ b/macosx/tkMacOSXWm.c
@@ -1048,7 +1048,7 @@ TkWmDeadWindow(
void
TkWmSetClass(
- TkWindow *winPtr) /* Newly-created top-level window. */
+ TCL_UNUSED(TkWindow *)) /* Newly-created top-level window. */
{
return;
}
@@ -1235,7 +1235,7 @@ Tk_WmObjCmd(
static int
WmAspectCmd(
- Tk_Window tkwin, /* Main window of the application. */
+ TCL_UNUSED(Tk_Window), /* Main window of the application. */
TkWindow *winPtr, /* Toplevel to work with */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
@@ -1503,7 +1503,7 @@ WmGetAttribute(
static int
WmAttributesCmd(
- Tk_Window tkwin, /* Main window of the application. */
+ TCL_UNUSED(Tk_Window), /* Main window of the application. */
TkWindow *winPtr, /* Toplevel to work with */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
@@ -1575,7 +1575,7 @@ WmAttributesCmd(
static int
WmClientCmd(
- Tk_Window tkwin, /* Main window of the application. */
+ TCL_UNUSED(Tk_Window), /* Main window of the application. */
TkWindow *winPtr, /* Toplevel to work with */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
@@ -1720,7 +1720,7 @@ WmColormapwindowsCmd(
static int
WmCommandCmd(
- Tk_Window tkwin, /* Main window of the application. */
+ TCL_UNUSED(Tk_Window), /* Main window of the application. */
TkWindow *winPtr, /* Toplevel to work with */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */