|
Hello,
I have the compilation warning: core.c: At top level: core.c:1594: warning: no previous prototype for ‘usbi_log_v’ The problem is that usbi_log_v() is declared in libusbi.h only for Windows. #if !defined(_MSC_VER) || _MSC_VER > 1200 blabla #else /* !defined(_MSC_VER) || _MSC_VER > 1200 */ void usbi_log_v(struct libusb_context *ctx, enum usbi_log_level level, const char *function, const char *format, va_list args); #endif Proposed patch attached. I just moved the declaration of usbi_log_v() outside the #if for MSC Thanks -- Dr. Ludovic Rousseau ------------------------------------------------------------------------------ This SF.net email is sponsored by Sprint What will you do first with EVO, the first 4G phone? Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first _______________________________________________ Libusb-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/libusb-devel |
|
Ludovic Rousseau wrote:
>> Proposed patch attached. I just moved the declaration of usbi_log_v() >> outside the #if for MSC That should be fine. In everything but MSVC6, usbi_log_v is only referenced in core.c inside usbi_log (which comes AFTER in the file), so I figured nothing else needed the prototype. In MSVC6, the usbi_log is bypassed, and calls to usbi_log_v occur in static inlines inside libusbi.h, rather than core.c. No other compiler complained at me (including when I tested with gcc). But I probably should have unconditionally prototyped it anyway. For reducing redundancy, LOG_BODY could have been made the body of usbi_log(), but it would have been more confusing, IMO. Michael ------------------------------------------------------------------------------ This SF.net email is sponsored by Sprint What will you do first with EVO, the first 4G phone? Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first _______________________________________________ Libusb-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/libusb-devel |
|
2010/6/27 Michael Plante <[hidden email]>:
> Ludovic Rousseau wrote: >>> Proposed patch attached. I just moved the declaration of usbi_log_v() >>> outside the #if for MSC > > That should be fine. In everything but MSVC6, usbi_log_v is only referenced > in core.c inside usbi_log (which comes AFTER in the file), so I figured > nothing else needed the prototype. When a function is defined gcc check that the function is conform to its declaration. If no declaration was made before then gcc complaints with a warning. -Wmissing-declarations Warn if a global function is defined without a previous declaration. Do so even if the definition itself provides a prototype. Use this option to detect global functions that are not declared in header files. In C++, no warnings are issued for function templates, or for inline functions, or for functions in anonymous namespaces. > In MSVC6, the usbi_log is bypassed, and > calls to usbi_log_v occur in static inlines inside libusbi.h, rather than > core.c. No other compiler complained at me (including when I tested with > gcc). But I probably should have unconditionally prototyped it anyway. > > For reducing redundancy, LOG_BODY could have been made the body of > usbi_log(), but it would have been more confusing, IMO. Maybe we should have two implementations for usbi_log: one for MSVCx and one for the rest of the universe. And use the #if dance in core.c instead of a .h Bye -- Dr. Ludovic Rousseau ------------------------------------------------------------------------------ This SF.net email is sponsored by Sprint What will you do first with EVO, the first 4G phone? Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first _______________________________________________ Libusb-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/libusb-devel |
|
Ludovic Rousseau wrote:
>> -Wmissing-declarations Odd. I know I tested it (in Linux). Maybe this warning is not enabled by default (in -Wall)? I just retested, and gcc-4.1.2 doesn't warn with default argument-less autogen.sh/make. I haven't switched my system compiler to 4.4.3 yet, but maybe it will then? Anyway, thank you for fixing it. >> > For reducing redundancy, LOG_BODY could have been made the body of >> > usbi_log(), but it would have been more confusing, IMO. >> >> Maybe we should have two implementations for usbi_log: one for MSVCx >> and one for the rest of the universe. Sorry, but that makes no sense. A function would not work in this case; it had to be a macro for the va_args problem. All I'm saying here is I was trying to keep my changes limited to just this one compiler. The MSVC6 implementation *MAY* work for other compilers, at least to the level that only one line would need to be #ifdefed (for a reason not even discussed in this thread), instead of a few dozen. But I did not try, as the MSVC6 implementation is less straightforward. By #ifdefing it, I chose not to force that complexity on everyone else. >> And use the #if dance in core.c instead of a .h Moving it to a different file is a distinct issue that solves no technical issues, only aesthetic (which may be sufficient reason for some). It has the disadvantage of losing the inlining. Anyway, I'm fine with your patch, and I prefer we not get bogged down on this. Perhaps I shouldn't have mentioned it, but I was trying to be clear about why that prototype was inserted in the first place. I'm beginning to think that every time I go back and re-explain anything, I open new cans of worms. Maybe I should just say the minimum in the future. Michael ------------------------------------------------------------------------------ This SF.net email is sponsored by Sprint What will you do first with EVO, the first 4G phone? Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first _______________________________________________ Libusb-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/libusb-devel |
|
In reply to this post by Ludovic Rousseau
I got some positive comments about my patch. But nobody applied it yet.
So I propose it again. PS: I can't create new tickets right now. 2010/6/27 Ludovic Rousseau <[hidden email]>: > Hello, > > I have the compilation warning: > > core.c: At top level: > core.c:1594: warning: no previous prototype for ‘usbi_log_v’ > > The problem is that usbi_log_v() is declared in libusbi.h only for Windows. > > #if !defined(_MSC_VER) || _MSC_VER > 1200 > > blabla > > #else /* !defined(_MSC_VER) || _MSC_VER > 1200 */ > > void usbi_log_v(struct libusb_context *ctx, enum usbi_log_level level, > const char *function, const char *format, va_list args); > > #endif > > Proposed patch attached. I just moved the declaration of usbi_log_v() > outside the #if for MSC > > Thanks Dr. Ludovic Rousseau ------------------------------------------------------------------------------ Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)! Finally, a world-class log management solution at an even better price-free! Download using promo code Free_Logger_4_Dev2Dev. Offer expires February 28th, so secure your free ArcSight Logger TODAY! http://p.sf.net/sfu/arcsight-sfd2d _______________________________________________ Libusb-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/libusb-devel |
|
In reply to this post by Michael Plante
Hello,
This compiler warning issue is still not fixed. Should I open a ticket? Regenerated patch attached. Thanks 2010/6/27 Michael Plante <[hidden email]>: > Ludovic Rousseau wrote: >>> -Wmissing-declarations > > Odd. I know I tested it (in Linux). Maybe this warning is not enabled by > default (in -Wall)? I just retested, and gcc-4.1.2 doesn't warn with > default argument-less autogen.sh/make. I haven't switched my system > compiler to 4.4.3 yet, but maybe it will then? Anyway, thank you for fixing > it. -- Dr. Ludovic Rousseau ------------------------------------------------------------------------------ BlackBerry® DevCon Americas, Oct. 18-20, San Francisco, CA http://p.sf.net/sfu/rim-devcon-copy2 _______________________________________________ Libusb-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/libusb-devel |
|
Ludovic Rousseau wrote:
>> This compiler warning issue is still not fixed. Should I open a ticket? Probably not a bad idea if you don't see anything in a day or two. It probably just got lost though. I don't remember any objections to this change. Michael ------------------------------------------------------------------------------ BlackBerry® DevCon Americas, Oct. 18-20, San Francisco, CA http://p.sf.net/sfu/rim-devcon-copy2 _______________________________________________ Libusb-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/libusb-devel |
| Powered by Nabble | See how NAML generates this page |
