Newbie question : __format__ ?

瀏覽次數:13 次
跳到第一則未讀訊息

Thierry Jeanneret

未讀,
2015年2月23日 中午12:07:532015/2/23
收件者:fltkg...@googlegroups.com
Hello There,

I am trying to use the library from Xcode V 6.1.1. I can build all the modules with one warning : 

In file included from file.cxx:296:

In file included from ./Fl_Widget_Type.h:23:

./Fl_Type.h:805:48: warning: attribute declaration must precede definition [-Wignored-attributes]

void write_string(const char *,...) __fl_attr((__format__ (__printf__, 1, 2)));

                                               ^

./Fl_Type.h:799:41: note: expanded from macro '__fl_attr'

#    define __fl_attr(x) __attribute__ (x)

                                        ^

file.cxx:89:6: note: previous definition is here

void write_string(const char *format, ...) {

     ^

1 warning generated.


I have this warning at least in the file Fl_type.h.  


Can someone help me to understand this warning and make it disappear ?


Thanks in advance, 


Thierry


Ian MacArthur

未讀,
2015年2月23日 下午4:37:232015/2/23
收件者:fltkg...@googlegroups.com
To be honest, I’m puzzled how you are managing to generate it...

The __format__ modifier is telling the compiler that the function just declared takes a variable argument list in the style of printf, it’s used to allow the compiler to make "cleverer” judgements about the code as it compiles it.

It’s not supported by all compilers, but any recent gcc will, and pretty much all compilers that expose a gcc-compatible personality (which covers icc, for example, and in this case the clang compilers that Apple now favour.)

Assuming you are compiling with some clang variant then, I’d have to speculate that for some reason it is *not* using it’s "gcc personality” to compile the code, and that does seem very odd...

I see Ingwie has suggested you try just building at the command line using the traditional "./configure ; make" sequence, and that’s certainly worth a try.

FWIW, I do not see this warning when building on OSX, and I don’t think anyone else has reported it either. Manolo does a lot of work in OSX and I guess if this was an issue he’d have mentioned it. (Or, more likely, fixed it already!)

Can you give us any insights into what you might have “tweaked” that might have induce this behaviour?





回覆所有人
回覆作者
轉寄
0 則新訊息