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

Fix 2 warnings when building with Clang #132

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rubenk
Copy link
Contributor

@rubenk rubenk commented Mar 20, 2016

attribute ((format (printf, 5, 6))) is supported by both GCC and Clang.

This fixes the following warnings:

In file included from log.c:33:
./log.h:42:48: warning: format attribute argument not supported: gnu_printf [-Wignored-attributes]
const char *fmt, ...) attribute ((format (gnu_printf, 5, 6)));
^
./log.h:43:73: warning: format attribute argument not supported: gnu_printf [-Wignored-attributes]
void log_write_direct(int log_id, const char *fmt, ...) attribute ((format (gnu_printf, 2, 3)));
^
2 warnings generated.

__attribute__ ((format (printf, 5, 6))) is supported by both GCC and Clang.

This fixes the following warnings:

In file included from log.c:33:
./log.h:42:48: warning: format attribute argument not supported: gnu_printf [-Wignored-attributes]
        const char *fmt, ...)  __attribute__ ((format (gnu_printf, 5, 6)));
                                               ^
./log.h:43:73: warning: format attribute argument not supported: gnu_printf [-Wignored-attributes]
void log_write_direct(int log_id, const char *fmt, ...) __attribute__ ((format (gnu_printf, 2, 3)));
                                                                        ^
2 warnings generated.
@karlheyes
Copy link
Owner

will need to looked at in more detail. The problem with this is, while it is correct, the problem case is, as ever, windows. The *printf routines on the windows platform are rubbish (although may be better in the latest update), so I use the mingw versions which really require the gnu_printf setting to enforce it, but likewise causes an issue on clang.

Can you verify if the following builds on the unpatched tree without issue, using clang

make CFLAGS="-Dgnu_printf=print"

if so then I can just force the same macro if GNUG is unset

karl.

@rubenk
Copy link
Contributor Author

rubenk commented Mar 21, 2016

Ah yes, printf and Windows, I didn't consider that.
If I recall correctly mingw has a macro for this, __MINGW_PRINTF_FORMAT.

In any case, ./configure CC=clang CFLAGS="-Wall -g -O2 -Dgnu_printf=printf" && make silences the warning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants