On Wed, 28 Aug 2024, LIU Hao wrote:

在 2024-08-28 03:15, Pali Rohár 写道:
Use gcc's function attribute naked which omits any prologue or epilogue
sequences and for x86 is supported by gcc since version 8.0.0. It is also
supported by clang. For older gcc versions use existing code.

This change fixes compile warning:

stdio/_scprintf.c:32:20: warning: ‘init_scprintf’ used but never defined
  static int __cdecl init_scprintf(const char * __restrict__ format, ...);
                     ^~~~~~~~~~~~~

I think that introducing such complexity for just silencing a warning is an overkill.

I somewhat agree, but I don't have a very strong opinion on it. In one sense, we're lying to the compiler, when we claim something is a static function, but it doesn't exist in the C source of the translation unit, so it wouldn't surprise me if a future compiler could break this case.

If this file is only ever compiled for i686 then I would prefer the resolver function to be implemented in assembly. The `ASM_SYM` macro is no longer necessary.

I guess that's possible, but the more assembly code we have, the less maintainable it is. (I'm personally not very fluent in x86 assembly, contrary to arm/aarch64.)

A different way of getting rid of the warning, and making it safe for the compiler, would to just make the symbol extern instead of static, and adding e.g. a __mingw prefix to it. It's less elegant than having a static symbol, but feels like a reasonable tradeoff between safe and maintainable code, exposing symbols, and using fancy compiler features optionally.

(A way to make it less overkill could be to just require a compiler that supports the attribute. But I guess there can be users who want to use the latest mingw-w64 with old compilers too?)

// Martin

_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to