Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

`warning: unused parameter` when -Wextra is set to CFLAGS #39

Closed
kubo opened this Issue Oct 15, 2017 · 1 comment

Comments

Projects
None yet
2 participants
@kubo
Copy link

kubo commented Oct 15, 2017

When -Wextra is added to CFLAGS, gcc complains many unused parameter warnings on Linux.

$ make
mkdir build
mkdir lib
gcc -c -Iinclude -O2 -g -Wall -fPIC -Wextra src/dpiConn.c -obuild/dpiConn.o
src/dpiConn.c: In function ‘dpiConn__decrementOpenChildCount’:
src/dpiConn.c:222:63: warning: unused parameter ‘error’ [-Wunused-parameter]
 int dpiConn__decrementOpenChildCount(dpiConn *conn, dpiError *error)
                                                               ^
gcc -c -Iinclude -O2 -g -Wall -fPIC -Wextra src/dpiContext.c -obuild/dpiContext.o
src/dpiContext.c: In function ‘dpiContext__initCommonCreateParams’:
src/dpiContext.c:33:58: warning: unused parameter ‘context’ [-Wunused-parameter]
 int dpiContext__initCommonCreateParams(const dpiContext *context,
                                                          ^
src/dpiContext.c:34:50: warning: unused parameter ‘error’ [-Wunused-parameter]
         dpiCommonCreateParams *params, dpiError *error)
                                                  ^
...

Could you suppress these warnings?

Add the following macro to src/dpiImpl.h.

#ifdef __GNUC__
#define UNUSED __attribute((unused))
#else
#define UNUSED
#endif

And then use the macro after unused parameters as follows:

int dpiConn__decrementOpenChildCount(dpiConn *conn, dpiError *error UNUSED)

anthony-tuininga added a commit that referenced this issue Oct 16, 2017

Remove unused parameters and add __atribute((unused)) for mandatory p…
…arameters

in callbacks which are unused (for the gcc compiler), as requested
(#39).
@anthony-tuininga

This comment has been minimized.

Copy link
Member

anthony-tuininga commented Oct 16, 2017

Thanks for the suggestion. I removed the unused parameters where I could do so and added the UNUSED directive where I couldn't (callbacks, for example).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.